List of usage examples for org.openqa.selenium By xpath
public static By xpath(String xpathExpression)
From source file:at.tugraz.ist.catroweb.catroid.LicenseTests.java
License:Open Source License
@Test(groups = { "visibility" }, description = "check privacy policy link/page") public void privacyPolicy() throws Throwable { try {/*from www . j av a 2s. c o m*/ openLocation(); By privacy = By.xpath("//*[@id='largeFooterMenu']/div[1]/ul/li[1]/a"); assertTrue(isElementPresent(privacy)); clickAndWaitForPopUp(privacy); assertRegExp(".*Privacy Policy.*", driver().getTitle()); closePopUp(); } catch (AssertionError e) { captureScreen("LicenseTests.privacyPolicy"); throw e; } catch (Exception e) { captureScreen("LicenseTests.privacyPolicy"); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.LicenseTests.java
License:Open Source License
@Test(groups = { "visibility" }, description = "check privacy policy link/page") public void privacyPolicyMobile() throws Throwable { try {// w w w . j a va2s.c om openMobileLocation(); assertTrue(isElementPresent(By.id("footerMoreButton"))); driver().findElement(By.id("footerMoreButton")).click(); By privacy = By.xpath("//*[@id='mobileFooterMenu']/ul/li[1]/a"); assertTrue(isElementPresent(privacy)); clickAndWaitForPopUp(privacy); assertRegExp(".*Privacy Policy.*", driver().getTitle()); closePopUp(); } catch (AssertionError e) { captureScreen("LicenseTests.privacyPolicyMobile"); throw e; } catch (Exception e) { captureScreen("LicenseTests.privacyPolicyMobile"); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.LicenseTests.java
License:Open Source License
@Test(groups = { "visibility", "popupwindows" }, description = "check terms of use link/page") public void termsOfUse() throws Throwable { try {/*from w w w .j a v a2s. c o m*/ openLocation(); driver().findElement(By.xpath("//*[@id='largeFooterMenu']/div[1]/ul/li[2]/a")).click(); ajaxWait(); assertTrue(isTextPresent("Welcome to the Catrobat community!")); assertTrue(isTextPresent( "As part of the Catrobat community, you are sharing programs and ideas with people:")); // click onto licenseofuploadedprojects link clickAndWaitForPopUp(By.xpath("//div[@class='licenseText']/ul[3]/li[4]/a[1]")); assertRegExp(".*Licenses of uploaded Catrobat programs.*", driver().getTitle()); closePopUp(); // click onto licenseofsystem link clickAndWaitForPopUp(By.xpath("//div[@class='licenseText']/ul[4]/li[3]/a[1]")); assertRegExp(".*Licenses of the Catrobat System.*", driver().getTitle()); closePopUp(); clickAndWaitForPopUp(By.xpath("//div[@class='licenseText']/ul[4]/li[3]/a[2]")); assertRegExp(".*Catrobat.*", driver().getTitle()); closePopUp(); // click onto termsofservice link clickAndWaitForPopUp(By.xpath("//div[@class='licenseText']/ul[5]/li[3]/a[1]")); assertRegExp(".*Terms of Service.*", driver().getTitle()); closePopUp(); assertTrue(driver().findElement(By.xpath("//p[@class='licenseText'][7]/a")).getAttribute("href") .contains("mailto:webmaster@catrobat.org?subject=Terms%20of%20Use")); } catch (AssertionError e) { captureScreen("LicenseTests.termsOfUse"); throw e; } catch (Exception e) { captureScreen("LicenseTests.termsOfUse"); throw e; } }
From source file:at.tugraz.ist.catroweb.catroid.LicenseTests.java
License:Open Source License
@Test(groups = { "visibility", "popupwindows" }, description = "check terms of use link/page") public void termsOfUseMobile() throws Throwable { try {//from ww w .j ava 2 s.c om openMobileLocation(); assertTrue(isElementPresent(By.id("footerMoreButton"))); driver().findElement(By.id("footerMoreButton")).click(); ajaxWait(); driver().findElement(By.xpath("//*[@id='mobileFooterMenu']/ul/li[2]/a")).click(); ajaxWait(); assertTrue(isTextPresent("Welcome to the Catrobat community!")); assertTrue(isTextPresent( "As part of the Catrobat community, you are sharing programs and ideas with people:")); // click onto licenseofuploadedprojects link clickAndWaitForPopUp(By.xpath("//div[@class='licenseText']/ul[3]/li[4]/a[1]")); assertRegExp(".*Licenses of uploaded Catrobat programs.*", driver().getTitle()); closePopUp(); // click onto licenseofsystem link clickAndWaitForPopUp(By.xpath("//div[@class='licenseText']/ul[4]/li[3]/a[1]")); assertRegExp(".*Licenses of the Catrobat System.*", driver().getTitle()); closePopUp(); clickAndWaitForPopUp(By.xpath("//div[@class='licenseText']/ul[4]/li[3]/a[2]")); assertRegExp(".*Catrobat.*", driver().getTitle()); closePopUp(); // click onto termsofservice link clickAndWaitForPopUp(By.xpath("//div[@class='licenseText']/ul[5]/li[3]/a[1]")); assertRegExp(".*Terms of Service.*", driver().getTitle()); closePopUp(); assertTrue(driver().findElement(By.xpath("//p[@class='licenseText'][7]/a")).getAttribute("href") .contains("mailto:webmaster@catrobat.org?subject=Terms%20of%20Use")); } catch (AssertionError e) { captureScreen("LicenseTests.termsOfUseMobile"); throw e; } catch (Exception e) { captureScreen("LicenseTests.termsOfUseMobile"); throw e; } }
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 imprint() throws Throwable { try {/*from w w w .ja v a 2 s . c o m*/ openLocation(); clickAndWaitForPopUp(By.xpath("//*[@id='largeFooterMenu']/div[1]/ul/li[3]/a")); assertRegExp(".*Imprint.*", driver().getTitle()); closePopUp(); } catch (AssertionError e) { captureScreen("LicenseTests.imprint"); throw e; } catch (Exception e) { captureScreen("LicenseTests.imprint"); throw e; } }
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 ww. ja 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 {//ww w.j a 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")); 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 . ja v a 2s. 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 w w w . j a va 2 s. c o 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.MyProjectsTests.java
License:Open Source License
@Test(groups = { "functionality" }, description = "try to delete one of my projects") public void deleteMyProject() throws Throwable { try {/*w ww.j a v a 2 s .co m*/ // upload a project String title = "Delete this project"; String response = projectUploader .upload(CommonData.getUploadPayload(title, "", "", "", "", "", "", "")); assertEquals("200", CommonFunctions.getValueFromJSONobject(response, "statusCode")); // delete uploaded project login("profile"); By project = By.xpath("//a[@title=\"" + title + "\"]"); By deleteButton = By.xpath("//a[@title=\"" + title + "\"]/../div"); assertTrue(isElementPresent(project)); assertTrue(isElementPresent(deleteButton)); clickOkOnNextConfirmationBox(); driver().findElement(deleteButton).click(); ajaxWait(); assertFalse(isElementPresent(project)); assertProjectNotPresent(title); } catch (AssertionError e) { captureScreen("deleteMyProject.deleteMyProject"); throw e; } catch (Exception e) { captureScreen("deleteMyProject.deleteMyProject"); throw e; } }