@Test public void sanityTest() { LandingPage page1 = new LandingPage(driver); LandingPage onlandingPage = page1.goToLandingPage(); LoginPage onloginPage = onlandingPage.goToLoginPage(); HomePage onHomePage = onloginPage.loginToAccount(); }
@Test @InSequence(2) public void adminCreateApplicationTest() { driver.get(contextRoot.toExternalForm()); loginPage.waitForPage(); loginPage.login(ADMIN_USERNAME, PASSWORD); if (passwordChangePage.isPagePresent()) { passwordChangePage.changePassword(PASSWORD); } navigation.goToApplications(); pushAppsPage.waitForPage(); navigation.goToApplications(); // initially there shouldn't exist any push applications while (!pushAppsPage.getApplicationList().isEmpty()) { Application application = pushAppsPage.getApplicationList().get(0); application.remove(); modal.waitForDialog(); modal.confirmName(application.getName()); modal.remove(); } pushAppsPage.pressCreateButton(); pushAppEditPage.registerNewPushApp(ADMIN_APPLICATION, ""); header.logout(); }
@Test @InSequence(1) public void createNewUserTest() throws URISyntaxException { driver.get(authContextRoot.toURI().resolve(CONSOLE_PATH).toString()); loginPage.waitForPage(); loginPage.login(ADMIN_USERNAME, PASSWORD); if (passwordChangePage.isPagePresent()) { passwordChangePage.changePassword(PASSWORD); } keyCloakNavigation.waitForPage(); keyCloakNavigation.users(); User newUser = new User(); newUser.setUsername(NEW_USER_USERNAME); newUser.setEnabled(true); usersPage.addUser(newUser); userPageNavBar.roleMappings(); roleMappingsPage.assignRole("developer"); userPageNavBar.credentials(); credentialsPage.setPassword(NEW_USER_PASSWORD); modal.waitForDialog(); modal.remove(); dropdown.click("Sign Out"); loginPage.waitForPage(); }
@Test public void testLogin() { WebDriver driver = new FirefoxDriver(); LoginPage loginPage = new LoginPage(driver); // UserHomePage userHomePage=new UserHomePage(driver); UserHomePage userHomePage = loginPage.testLogin(); driver.quit(); }
/** * Verify that a logging in with a fake user will not grant the user access and redisplay the * login panel. * * @throws Exception if error */ @Test public void loginWithFakeCredentials() throws Exception { drone.navigateTo(shareUrl); LoginPage page = (LoginPage) ShareUtil.loginAs(drone, shareUrl, "fake-admin", "fake-password"); Assert.assertTrue(page.isBrowserTitle("login")); Assert.assertTrue(page.hasErrorMessage()); Assert.assertTrue(page.getErrorMessage().length() > 1); }
@And("^user click on (.*) below to perform actions on application$") public void user_perform_below_actions_on_application(String link) { if (link.equalsIgnoreCase("GiftCards")) { loginPage.giftCardsLink().click(); loginPage.clickGiftsTyBeans().click(); } if (link.equalsIgnoreCase("cards")) { loginPage.cardsLink().click(); } }
@Test @InSequence(7) public void newUserApplicationListTest() { driver.get(contextRoot.toExternalForm()); loginPage.waitForPage(); loginPage.login(NEW_USER_USERNAME, NEW_USER_PASSWORD); if (passwordChangePage.isPagePresent()) { passwordChangePage.changePassword(NEW_USER_PASSWORD); } navigation.goToApplications(); pushAppsPage.waitForPage(); assertEquals(1, pushAppsPage.countApplications()); assertTrue(pushAppsPage.applicationExists(NEW_USER_APPLICATION, "")); }
@And("^successfully add to basket (.*) should display$") public void successfully_add_to_basket_message_should_display(String message) { // loginPage.addToBasketMessage(); // Assert.assertEquals("The requested quantity for \"Yankee Candle Beach Flowers Small Jar\" is // not available.",loginPage.addToBasketMessage()); loginPage.addToBasketMessage(); }
/** * Log a user into Alfresco with valid credentials and then logout * * @throws Exception if error */ @Test public void loginAndLogout() throws Exception { drone.navigateTo(shareUrl); LoginPage page = drone.getCurrentPage().render(); Assert.assertTrue(page.isBrowserTitle("login")); Assert.assertFalse(page.hasErrorMessage()); DashBoardPage dashboardPage = (DashBoardPage) ShareUtil.loginAs(drone, shareUrl, username, password); dashboardPage.render(); Assert.assertFalse(page.isBrowserTitle("login")); Assert.assertTrue(dashboardPage.isBrowserTitle("dashboard")); Assert.assertTrue(dashboardPage.isLoggedIn()); SharePage pageResponse = dashboardPage.getNav().logout().render(); Assert.assertTrue(pageResponse.isBrowserTitle("login")); }
@Then("^I should get message (.*)$") public void I_should_only_login_with_valid_details(String loginValidation) { Assert.assertEquals(loginValidation, loginPage.loginSuccess()); // Assert.assertEquals(loginValidation,loginPage.getUserNameValidation()); // Assert.assertEquals(loginValidation,loginPage.getPasswordMessage()); }
@Before public void setUp() { loginPage = new LoginPage(); String email = "*****@*****.**"; String password = "******"; String userName = "******"; mainApp = loginPage.loginAs(email, password, userName); }
@Test public void testRegistrationWhenLoggedIn() { WebDriver driver = driverService.getSharedWebDriver(); LoginPage.autoLogin(driver); RegistrationPage registrationPage = RegistrationPage.open(driver); registrationPage.register(RandomStringUtils.randomAlphabetic(15)); assertTrue(driver.findElements(By.cssSelector(".alert-success")).isEmpty()); assertEquals(urlFor("/"), driver.getCurrentUrl()); }
@Test @InSequence(0) public void activateDeveloperTest() throws URISyntaxException { String ble = contextRoot.toExternalForm(); driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS); driver.get(authContextRoot.toURI().resolve(CONSOLE_PATH).toString()); loginPage.waitForPage(); loginPage.login(ADMIN_USERNAME, PASSWORD); if (passwordChangePage.isPagePresent()) { passwordChangePage.changePassword(PASSWORD); } keyCloakNavigation.waitForPage(); keyCloakNavigation.users(); usersPage.activateUser(DEVELOPER_USERNAME); dropdown.click("Sign Out"); loginPage.waitForPage(); }
@Test @InSequence(3) public void newUserCreateApplicationTest() { driver.get(contextRoot.toExternalForm()); loginPage.waitForPage(); loginPage.login(NEW_USER_USERNAME, NEW_USER_PASSWORD); if (passwordChangePage.isPagePresent()) { passwordChangePage.changePassword(NEW_USER_PASSWORD); } navigation.goToApplications(); pushAppsPage.waitForPage(); navigation.goToApplications(); pushAppsPage.pressCreateButton(); pushAppEditPage.registerNewPushApp(NEW_USER_APPLICATION, ""); header.logout(); }
@Test @InSequence(6) public void adminApplicationListTest() { driver.get(contextRoot.toExternalForm()); loginPage.login(ADMIN_USERNAME, PASSWORD); if (passwordChangePage.isPagePresent()) { passwordChangePage.changePassword(PASSWORD); } navigation.goToApplications(); pushAppsPage.waitForPage(); assertEquals(3, pushAppsPage.countApplications()); assertTrue(pushAppsPage.applicationExists(ADMIN_APPLICATION, "")); assertTrue(pushAppsPage.applicationExists(DEVELOPER_APPLICATION, "")); assertTrue(pushAppsPage.applicationExists(NEW_USER_APPLICATION, "")); header.logout(); loginPage.waitForPage(); }
@BeforeClass public void setUp() throws Exception { // enabling Webservice webService = Service.create(new URL(url + "?wsdl"), new QName(namespaceUri, localPart)); buecherService = webService.getPort(BuecherService.class); // creating some books in the store createTestBooks(numOfBooks); // enabling Selenium Gui driver service // and login product = new Product(); product.title = "Books Project (" + browser + ")"; product.description = "Contains a story for every missing book..."; SeleniumProperties.browser = browser; GeneralPage.setDriver(SeleniumProperties.browser); GeneralPage.start(); LoginPage loginPage = new LoginPage(); startPage = loginPage.login(SeleniumProperties.adminName, SeleniumProperties.adminPwd); }
@Test @InSequence(4) public void developerApplicationListTest() { driver.get(contextRoot.toExternalForm()); loginPage.login(DEVELOPER_USERNAME, DEVELOPER_PASSWORD); if (passwordChangePage.isPagePresent()) { passwordChangePage.changePassword(DEVELOPER_PASSWORD); } navigation.goToApplications(); pushAppsPage.waitForPage(); assertEquals(0, pushAppsPage.countApplications()); assertFalse(pushAppsPage.applicationExists(ADMIN_APPLICATION, "")); }
@And("^I submit following valid details to sign in$") public void I_enter_following_valid_details_to_sign_in(DataTable tables) throws Throwable { List<Map<String, String>> maps = tables.asMaps(); for (Map<String, String> mp : maps) { signin.enterFirstname().clear(); signin.enterFirstname().sendKeys(mp.get("firstname")); signin.lastName().clear(); signin.lastName().sendKeys(mp.get("lastname")); signin.emailAddress().clear(); signin.emailAddress().sendKeys(mp.get("email")); signin.password().clear(); signin.password().sendKeys(mp.get("password")); signin.confirmPassword().clear(); signin.confirmPassword().sendKeys(mp.get("confirmpassword")); loginPage.clickSignInButton(); } }
@Given("^I m on clinton application home page$") public void I_m_on_clinton_application_home_page() { loginPage.clintonHomepage("http://www.clintoncards.co.uk"); }
@When("^I enter(.*) and (.*)$") public void password(String username, String password) { loginPage.i_enter_username_password(username, password); }
@Given("^I am on currys home page$") public void i_navigate_homepage() { loginPage.homePage("https://secure.currys.co.uk/gbuk/s/authentication.html"); }
@Then("^I should login successfully$") public void i_should_login_successfully() { loginPage.validateTitle(); // Assert.assertEquals(expect," Hello selenium"); }
@And("^I click login button$") public void I_click_login_button() { loginPage.loginButton(); }
@When("^I type my credentials as(.*) and(.*)$") public void enter_username_password(String user, String pass) { loginPage.i_enter_username_password(user, pass); }
@Then("^click on basket link$") public void I_am_on_sports_page() throws Throwable { loginPage.navigateToBaset(); }
@And("^checkout and verify the same (.*) item added to basket$") public void verify_validationMessage(String product) { loginPage.checkoutButton().click(); Assert.assertTrue(loginPage.getProductItemByLinkText(product).isDisplayed()); }
@And("^user click (.*) to add item$") public void user_click_addtobasket_to_add_item(String added) { loginPage.userAddToCartButtonClick(); }
@When("^I click register button$") public void I_click_register_button() { loginPage.clickRegister(); }
@Then("^I am on yahoo page$") public void I_am_on_yahoo_page() throws Throwable { loginPage.navigateToAUrl("http://currys.co.uk"); }
@Given("^I am on main home page$") public void i_am_on_currys_homepage() { loginPage.openBrowser("https://secure.currys.co.uk/gbuk/s/authentication.html"); }