List of usage examples for org.openqa.selenium By id
public static By id(String id)
From source file:at.tugraz.ist.catroweb.catroid.LicenseTests.java
License:Open Source License
@Test(groups = { "visibility", "popupwindows" }, description = "check imprint link/page") public void imprintMobile() throws Throwable { try {/*from w w w . j a v a 2 s . c o m*/ openMobileLocation(); assertTrue(isElementPresent(By.id("footerMoreButton"))); driver().findElement(By.id("footerMoreButton")).click(); ajaxWait(); clickAndWaitForPopUp(By.xpath("//*[@id='mobileFooterMenu']/ul/li[3]/a")); assertRegExp(".*Imprint.*", driver().getTitle()); closePopUp(); } catch (AssertionError e) { captureScreen("LicenseTests.imprintMobile"); throw e; } catch (Exception e) { captureScreen("LicenseTests.imprintMobile"); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.LoginTests.java
License:Open Source License
@Test(dataProvider = "validLoginData", groups = { "functionality", "popupwindows" }, description = "check login with valid data") public void validLogin(HashMap<String, String> dataset) throws Throwable { try {/*from w ww. j a v a 2 s . c om*/ // test login openLocation(); assertTrue(isVisible(By.id("largeMenuButton"))); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); driver().findElement(By.id("loginUsername")).sendKeys(dataset.get("username")); driver().findElement(By.id("loginPassword")).sendKeys(dataset.get("password")); driver().findElement(By.id("loginSubmitButton")).click(); ajaxWait(); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); driver().findElement(By.id("menuProfileButton")).click(); ajaxWait(); assertTrue( containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), dataset.get("username"))); // test logout driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); assertTrue(isVisible(By.id("menuLogoutButton"))); driver().findElement(By.id("menuLogoutButton")).click(); ajaxWait(); assertTrue(isVisible(By.id("loginSubmitButton"))); } catch (AssertionError e) { captureScreen("LoginTests.validLogin." + dataset.get("username")); throw e; } catch (Exception e) { captureScreen("LoginTests.validLogin." + dataset.get("username")); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.LoginTests.java
License:Open Source License
@Test(dataProvider = "validLoginData", groups = { "functionality", "popupwindows" }, description = "if logged in, registration page should redirect to profile page") public void redirection(HashMap<String, String> dataset) throws Throwable { try {/*from ww w. java 2 s . c o m*/ // test login openLocation(); assertTrue(isVisible(By.id("largeMenuButton"))); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); driver().findElement(By.id("loginUsername")).sendKeys(dataset.get("username")); driver().findElement(By.id("loginPassword")).sendKeys(dataset.get("password")); driver().findElement(By.id("loginSubmitButton")).click(); ajaxWait(); assertTrue( containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), dataset.get("username"))); openLocation("registration"); assertFalse(isTextPresent(CommonStrings.REGISTRATION_PAGE_TITLE.toUpperCase())); assertTrue( containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), dataset.get("username"))); } catch (AssertionError e) { captureScreen("LoginTests.redirection." + dataset.get("username")); throw e; } catch (Exception e) { captureScreen("LoginTests.redirection." + dataset.get("username")); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.LoginTests.java
License:Open Source License
@Test(groups = { "functionality" }, description = "try login with different lower upper case in username") public void differentCaseInUsernameLogin() throws Throwable { String username = "maxmustermann"; String password = "password"; String email = "max" + System.currentTimeMillis() + "@gmail.com"; String country = "Switzerland"; try {/*from ww w . j a va 2 s.co m*/ CommonFunctions.deleteUserFromDatabase(username); openLocation("registration/"); driver().findElement(By.id("registrationUsername")).sendKeys(username); driver().findElement(By.id("registrationPassword")).sendKeys(password); driver().findElement(By.id("registrationEmail")).sendKeys(email); driver().findElement(By.id("registrationCountry")).sendKeys(country); driver().findElement(By.id("registrationSubmit")).click(); ajaxWait(); assertTrue(containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), username)); logout("index"); openLocation("login"); driver().findElement(By.id("loginUsername")).sendKeys("MAXmUstermann"); driver().findElement(By.id("loginPassword")).sendKeys("password"); driver().findElement(By.id("loginSubmitButton")).click(); ajaxWait(); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); assertTrue(isVisible(By.id("menuProfileButton"))); driver().findElement(By.id("menuProfileButton")).click(); ajaxWait(); assertTrue(containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), username)); CommonFunctions.deleteUserFromDatabase(username); } catch (AssertionError e) { captureScreen("LoginTests.differentCaseInUsernameLogin." + username); throw e; } catch (Exception e) { captureScreen("LoginTests.differentCaseInUsernameLogin." + username); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.LoginTests.java
License:Open Source License
@Test(dataProvider = "invalidLoginData", groups = { "functionality", "popupwindows" }, description = "check login with invalid data; waitpage after five attempts") public void invalidLogin(HashMap<String, String> dataset) throws Throwable { try {/*w w w.ja v a 2 s. c o m*/ // test login openLocation(); assertTrue(isVisible(By.id("largeMenuButton"))); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); driver().findElement(By.id("loginUsername")).sendKeys(dataset.get("username")); driver().findElement(By.id("loginPassword")).sendKeys(dataset.get("password")); for (int i = 0; i < 5; i++) { driver().findElement(By.id("loginSubmitButton")).click(); ajaxWait(); assertTrue(isTextPresent("The password or username was incorrect.")); } CommonFunctions.removeAllBlockedIps(); for (int i = 0; i < 5; i++) { driver().findElement(By.id("loginSubmitButton")).click(); ajaxWait(); assertTrue(isTextPresent("The password or username was incorrect.")); } driver().findElement(By.id("loginSubmitButton")).click(); ajaxWait(); assertTrue(isTextPresent("Your IP-Address has been blocked for 30 seconds.")); CommonFunctions.removeAllBlockedIps(); } catch (AssertionError e) { captureScreen("LoginTests.invalidLogin." + dataset.get("username")); throw e; } catch (Exception e) { captureScreen("LoginTests.invalidLogin." + dataset.get("username")); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.PasswordRecoveryTests.java
License:Open Source License
@Test(groups = { "functionality" }, description = "check password recovery redirection if logged in") public void passwordRecoveryRedirectWhenLoggedIn() throws Throwable { try {//w w w.j av a 2 s . co m login("index"); openLocation("index", false); ajaxWait(); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); captureScreen("PasswordRecoveryTests.passwordRecoveryRedirectWhenLoggedIn"); assertTrue(isVisible(By.id("menuProfileButton"))); driver().findElement(By.id("menuProfileButton")).click(); ajaxWait(); assertTrue(containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), CommonData.getLoginUserDefault())); openLocation("passwordrecovery"); assertFalse(isTextPresent("Recover your password".toUpperCase())); assertTrue(containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), CommonData.getLoginUserDefault())); } catch (AssertionError e) { captureScreen("PasswordRecoveryTests.passwordRecoveryRedirectWhenLoggedIn"); throw e; } catch (Exception e) { captureScreen("PasswordRecoveryTests.passwordRecoveryRedirectWhenLoggedIn"); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.PasswordRecoveryTests.java
License:Open Source License
@Test(dataProvider = "passwordRecoveryResetUsernames", groups = { "functionality", "popupwindows" }, description = "check password recovery") public void passwordRecoveryReset(HashMap<String, String> dataset) throws Throwable { try {// ww w . ja v a 2 s. co m // do registration process first, to create a new user with known password openLocation("registration"); driver().findElement(By.id("registrationUsername")).sendKeys(dataset.get("registrationUsername")); driver().findElement(By.id("registrationPassword")).sendKeys(dataset.get("registrationPassword")); driver().findElement(By.id("registrationEmail")).sendKeys(dataset.get("registrationEmail")); driver().findElement(By.id("registrationCountry")).sendKeys(dataset.get("registrationCountry")); driver().findElement(By.id("registrationCity")).sendKeys(dataset.get("registrationCity")); driver().findElement(By.id("registrationMonth")).sendKeys(dataset.get("registrationMonth")); driver().findElement(By.id("registrationYear")).sendKeys(dataset.get("registrationYear")); driver().findElement(By.id("registrationGender")).sendKeys(dataset.get("registrationGender")); driver().findElement(By.id("registrationSubmit")).click(); ajaxWait(); assertTrue(containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), dataset.get("registrationUsername"))); // goto lost password page and test reset by email and nickname, at first // use some wrong nickname or email logout("passwordrecovery"); assertTrue(isTextPresent("Enter your nickname or email address:")); assertTrue(isElementPresent(By.id("passwordRecoveryUserdata"))); assertTrue(isElementPresent(By.id("passwordRecoverySendLink"))); driver().findElement(By.id("passwordRecoveryUserdata")).clear(); driver().findElement(By.id("passwordRecoveryUserdata")) .sendKeys(dataset.get("registrationUsername") + " to test"); driver().findElement(By.id("passwordRecoverySendLink")).click(); ajaxWait(); assertTrue(isTextPresent("The nickname or email address was not found.")); // check error message assertTrue(isTextPresent("Enter your nickname or email address:")); assertTrue(isElementPresent(By.id("passwordRecoveryUserdata"))); assertTrue(isElementPresent(By.id("passwordRecoverySendLink"))); // now use real name driver().findElement(By.id("passwordRecoveryUserdata")).clear(); driver().findElement(By.id("passwordRecoveryUserdata")).sendKeys(dataset.get("registrationUsername")); driver().findElement(By.id("passwordRecoverySendLink")).click(); ajaxWait(); // get recovery url and open it String recoveryUrl = driver().findElement(By.xpath("//*[@id='recoveryMessage']")).getText(); assertTrue(recoveryUrl.contains(Config.TESTS_BASE_PATH + "passwordrecovery?c=")); recoveryUrl = recoveryUrl.substring(recoveryUrl.indexOf("passwordrecovery")); openLocation(recoveryUrl); ajaxWait(); // enter 2short password assertTrue(isTextPresent("Please enter your new password:")); driver().findElement(By.id("passwordSavePassword")).clear(); driver().findElement(By.id("passwordSavePassword")).sendKeys("short"); driver().findElement(By.id("passwordSavePassword2")).clear(); driver().findElement(By.id("passwordSavePassword2")).sendKeys("short"); driver().findElement(By.id("passwordSaveSubmit")).click(); ajaxWait(); assertTrue(isTextPresent("Please enter your new password:")); assertTrue(isElementPresent(By.id("passwordSavePassword"))); assertTrue(driver().findElement(By.xpath("//*[@id='recoveryMessage']")).getText() .contains("password must have at least")); // enter the new password correctly driver().findElement(By.id("passwordSavePassword")).clear(); driver().findElement(By.id("passwordSavePassword")) .sendKeys(dataset.get("registrationPassword") + " new"); driver().findElement(By.id("passwordSavePassword2")).clear(); driver().findElement(By.id("passwordSavePassword2")) .sendKeys(dataset.get("registrationPassword") + " new"); driver().findElement(By.id("passwordSaveSubmit")).click(); ajaxWait(); assertTrue(containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), dataset.get("registrationUsername"))); // and try to login with the old credentials to verify password recovery // worked logout(); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); assertTrue(isElementPresent(By.id("loginSubmitButton"))); assertTrue(isVisible(By.id("loginSubmitButton"))); assertTrue(isVisible(By.id("loginUsername"))); assertTrue(isVisible(By.id("loginPassword"))); driver().findElement(By.id("loginUsername")).sendKeys(dataset.get("registrationUsername")); driver().findElement(By.id("loginPassword")).sendKeys(dataset.get("registrationPassword")); driver().findElement(By.id("loginSubmitButton")).click(); ajaxWait(); assertTrue(isTextPresent("The password or username was incorrect.")); // check bad login assertTrue(isVisible(By.id("loginSubmitButton"))); // and try to login now with the new credentials assertTrue(isVisible(By.id("loginSubmitButton"))); assertTrue(isVisible(By.id("loginUsername"))); assertTrue(isVisible(By.id("loginPassword"))); driver().findElement(By.id("loginUsername")).clear(); driver().findElement(By.id("loginUsername")).sendKeys(dataset.get("registrationUsername")); driver().findElement(By.id("loginPassword")).clear(); driver().findElement(By.id("loginPassword")).sendKeys(dataset.get("registrationPassword") + " new"); driver().findElement(By.id("loginSubmitButton")).click(); ajaxWait(); // check login driver().findElement(By.xpath("//*[@id='largeMenu']/div[2]/a")).click(); assertTrue(isTextPresent(CommonStrings.NEWEST_PROJECTS_PAGE_TITLE.toUpperCase())); ajaxWait(); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); assertTrue(isVisible(By.id("menuProfileButton"))); driver().findElement(By.id("menuProfileButton")).click(); ajaxWait(); assertTrue(containsElementText(By.xpath("//*[@id='largeMenuButton']/button[2]"), dataset.get("registrationUsername"))); // logout logout(); ajaxWait(); driver().findElement(By.id("largeMenuButton")).click(); ajaxWait(); assertTrue(isVisible(By.id("loginSubmitButton"))); assertTrue(isVisible(By.id("loginUsername"))); assertTrue(isVisible(By.id("loginPassword"))); // Recovery URL should not work again driver().get(this.webSite + Config.TESTS_BASE_PATH.substring(1) + recoveryUrl); ajaxWait(); assertEquals(driver().findElement(By.xpath("//*[@id='recoveryMessage']")).getText(), "Recovery hash was not found."); CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); } catch (AssertionError e) { captureScreen("PasswordRecoveryTests.passwordRecoveryReset." + dataset.get("registrationUsername")); throw e; } catch (Exception e) { captureScreen("PasswordRecoveryTests.passwordRecoveryReset." + dataset.get("registrationUsername")); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.ProfileTests.java
License:Open Source License
@Test(dataProvider = "loginAndChangeData", groups = { "functionality", "visibility" }, description = "check profile page") public void profilePageChangeUserData(HashMap<String, String> dataset) throws Throwable { try {/* w w w . j ava 2 s .com*/ openLocation("registration/"); driver().findElement(By.id("registrationUsername")).sendKeys(dataset.get("registrationUsername")); driver().findElement(By.id("registrationPassword")).sendKeys(dataset.get("registrationPassword")); driver().findElement(By.id("registrationEmail")).sendKeys(dataset.get("registrationEmail")); driver().findElement(By.id("registrationMonth")).sendKeys(dataset.get("registrationMonth")); driver().findElement(By.id("registrationYear")).sendKeys(dataset.get("registrationYear")); driver().findElement(By.id("registrationGender")).sendKeys(dataset.get("registrationGender")); (new Select(driver().findElement(By.id("registrationCountry")))) .selectByValue(dataset.get("registrationCountryID")); driver().findElement(By.id("registrationCity")).sendKeys(dataset.get("registrationCity")); driver().findElement(By.id("registrationSubmit")).click(); ajaxWait(); assertTrue(isTextPresent(dataset.get("registrationUsername"))); assertEquals(dataset.get("registrationEmail"), driver().findElement(By.xpath("//*[@id='profileEmail']/input")).getAttribute("value")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isVisible(By.xpath("//*[@id='profileNewPassword']/input"))); assertTrue(isVisible(By.xpath("//*[@id='profileRepeatPassword']/input"))); assertTrue(isVisible(By.id("profileSaveChanges"))); driver().findElement(By.xpath("//*[@id='profileNewPassword']/input")) .sendKeys(dataset.get("changedPassword")); driver().findElement(By.xpath("//*[@id='profileRepeatPassword']/input")) .sendKeys(dataset.get("changedPassword")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent("saved!")); openLocation("profile/"); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); driver().findElement(By.xpath("//*[@id='profileNewPassword']/input")) .sendKeys(dataset.get("registrationPassword")); driver().findElement(By.xpath("//*[@id='profileRepeatPassword']/input")) .sendKeys(dataset.get("changedPassword")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent(CommonStrings.PROFILE_PASSWORD_DIDNT_MATCH)); openLocation("profile/"); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); driver().findElement(By.xpath("//*[@id='profileNewPassword']/input")) .sendKeys(dataset.get("emptyPassword")); driver().findElement(By.xpath("//*[@id='profileRepeatPassword']/input")) .sendKeys(dataset.get("emptyPassword")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); openLocation("profile/"); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); driver().findElement(By.xpath("//*[@id='profileNewPassword']/input")) .sendKeys(dataset.get("shortPassword")); driver().findElement(By.xpath("//*[@id='profileRepeatPassword']/input")) .sendKeys(dataset.get("shortPassword")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent("Your password must have at least 6 characters.")); openLocation("profile/"); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); driver().findElement(By.xpath("//*[@id='profileNewPassword']/input")) .sendKeys(dataset.get("registrationPassword")); driver().findElement(By.xpath("//*[@id='profileRepeatPassword']/input")) .sendKeys(dataset.get("registrationPassword")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent("saved!")); openLocation("profile/"); By countrySelect = By.xpath("//*[@id='wrapper']/article/div[1]/div[2]/div[1]/div[4]/select"); Select selectCountry = new Select(driver().findElement(countrySelect)); assertEquals(dataset.get("registrationCountry"), selectCountry.getFirstSelectedOption().getText()); selectCountry.selectByValue(dataset.get("changedCountryID")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent("saved!")); openLocation("profile/"); selectCountry = new Select(driver().findElement(countrySelect)); assertEquals(dataset.get("changedCountry"), selectCountry.getFirstSelectedOption().getText()); selectCountry.selectByValue(dataset.get("registrationCountryID")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent("saved!")); openLocation("profile/"); selectCountry = new Select(driver().findElement(countrySelect)); assertEquals(dataset.get("registrationCountry"), selectCountry.getFirstSelectedOption().getText()); CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); } catch (AssertionError e) { CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); captureScreen("ProfileTests.profilePage." + dataset.get("registrationUsername")); throw e; } catch (Exception e) { CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); captureScreen("ProfileTests.profilePage." + dataset.get("registrationUsername")); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.ProfileTests.java
License:Open Source License
@Test(dataProvider = "loginAndChangeData", groups = { "functionality", "visibility" }, description = "upadte user avatar") public void profileChangeAvatarTest(HashMap<String, String> dataset) throws Throwable { try {/*ww w .j a v a2s . co m*/ openLocation("registration/"); driver().findElement(By.id("registrationUsername")).sendKeys(dataset.get("registrationUsername")); driver().findElement(By.id("registrationPassword")).sendKeys(dataset.get("registrationPassword")); driver().findElement(By.id("registrationEmail")).sendKeys(dataset.get("registrationEmail")); (new Select(driver().findElement(By.id("registrationCountry")))) .selectByValue(dataset.get("registrationCountryID")); driver().findElement(By.id("registrationMonth")).sendKeys(dataset.get("registrationMonth")); driver().findElement(By.id("registrationYear")).sendKeys(dataset.get("registrationYear")); driver().findElement(By.id("registrationGender")).sendKeys(dataset.get("registrationGender")); driver().findElement(By.id("registrationSubmit")).click(); ajaxWait(); By avatarImage = By.xpath("//*[@id='wrapper']/article/div[1]/div[1]/img"); assertTrue(driver().findElement(avatarImage).getAttribute("src") .contains("images/symbols/avatar_default.png")); makeVisible(By.id("profileAvatarFile"), ""); makeVisible(By.id("profileAvatarFileWrapper"), "arguments[0].style.width='100px';arguments[0].style.height='100px';"); driver().findElement(By.id("profileAvatarFile")) .sendKeys(Config.FILESYSTEM_BASE_PATH + Config.SELENIUM_GRID_TESTDATA + "test.zip"); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(driver().findElement(avatarImage).getAttribute("src") .contains("images/symbols/avatar_default.png")); assertTrue(isTextPresent("Invalid image, allowed image types are gif, png or jpeg.")); driver().findElement(By.id("profileAvatarFile")) .sendKeys(Config.FILESYSTEM_BASE_PATH + Config.SELENIUM_GRID_TESTDATA + "catrobat.png"); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertFalse(driver().findElement(avatarImage).getAttribute("src") .contains("images/symbols/avatar_default.png")); CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); } catch (AssertionError e) { CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); captureScreen("ProfileTests.profileChangeAvatarTest." + dataset.get("registrationUsername")); throw e; } catch (Exception e) { CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); captureScreen("ProfileTests.profileChangeAvatarTest." + dataset.get("registrationUsername")); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.ProfileTests.java
License:Open Source License
@Test(dataProvider = "emailTest", groups = { "functionality", "visibility" }, description = "check add/delete email") public void profilePageEmailTest(HashMap<String, String> dataset) throws Throwable { try {// w ww . j a v a 2s . c om openLocation("registration/"); driver().findElement(By.id("registrationUsername")).sendKeys(dataset.get("registrationUsername")); driver().findElement(By.id("registrationPassword")).sendKeys(dataset.get("registrationPassword")); driver().findElement(By.id("registrationEmail")).sendKeys(dataset.get("registrationEmail")); (new Select(driver().findElement(By.id("registrationCountry")))) .selectByValue(dataset.get("registrationCountryID")); driver().findElement(By.id("registrationMonth")).sendKeys(dataset.get("registrationMonth")); driver().findElement(By.id("registrationYear")).sendKeys(dataset.get("registrationYear")); driver().findElement(By.id("registrationGender")).sendKeys(dataset.get("registrationGender")); driver().findElement(By.id("registrationSubmit")).click(); ajaxWait(); assertTrue(containsElementText(By.xpath("//*[@id='wrapper']/article/header"), dataset.get("registrationUsername").toUpperCase())); clickOkOnNextConfirmationBox(); driver().findElement(By.xpath("//*[@id='profileEmail']/input")).clear(); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent( "Error while updating this e-mail address. You must have at least one validated e-mail address.")); openLocation("profile/"); driver().findElement(By.xpath("//*[@id='profileSecondEmail']/input")) .sendKeys(dataset.get("registrationEmail")); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent("This email address already exists.")); openLocation("profile/"); driver().findElement(By.xpath("//*[@id='profileSecondEmail']/input")) .sendKeys(dataset.get("secondEmail")); driver().findElement(By.id("profileSaveChanges")).click(); Alert alert = driver().switchTo().alert(); String message = alert.getText(); alert.accept(); assertRegExp(".*/emailvalidation.*", message); // get validation url and open it String validationUrl = getValidationUrl(message); openLocation(validationUrl + "_invalid"); assertTrue(isTextPresent("Recovery hash was not found.")); openLocation(validationUrl); assertTrue(isTextPresent("You have successfully validated your email address.")); openLocation("profile/"); ajaxWait(); clickOkOnNextConfirmationBox(); driver().findElement(By.xpath("//*[@id='profileEmail']/input")).clear(); driver().findElement(By.id("profileSaveChanges")).click(); ajaxWait(); assertTrue(isTextPresent("saved!")); CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); } catch (AssertionError e) { CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); captureScreen("ProfileTests.profilePage." + dataset.get("registrationUsername")); throw e; } catch (Exception e) { CommonFunctions.deleteUserFromDatabase(dataset.get("registrationUsername")); captureScreen("ProfileTests.profilePage." + dataset.get("registrationUsername")); throw e; } }