List of usage examples for org.openqa.selenium By xpath
public static By xpath(String xpathExpression)
From source file:cepfrontend.TestVerifyAssetReportHeaderShowAll.java
@Test public void TEST_AssetReportHeaderShowAll() throws Exception { ArrayList<String> expectedTableHeaders = new ArrayList<String>(Arrays.asList("Product", "Release", "Seats", "Serial # / Product Key", "License Type", "Language", "Contract #", "Subscription", "Support", "Group Name", "Subscription End Date", "Software Coordinator", "Contract Manager", "Territory Rights", "Territory Rights End Date")); loginAsCEPUser();/*from w w w . ja va 2 s .c om*/ CEP cep = utilCreateSubscriptionRenewal(); loginPage = cep.getLoginPage(); homePage = cep.getHomePage(); mainWindow.select(); homePage.click("showsFilerLink"); Util.sleep(5000); //Clicking on the Display drop down button String xpath = "//div[@class='ui-dropdown-header']/div"; findElementByXpath(xpath); // WebElement webElement1 = driver.findElement(By.xpath("//div[@class='ui-dropdown-header']/div")); // Util.sleep(3000); // Util.printMessage("webElement------"+webElement1); // driver.switchTo().activeElement(); // driver.findElement(By.xpath("//div[@class='ui-dropdown-header']/div")).click(); Util.sleep(5000); //Clicking on the check box in Display drop down button for (int second = 0;; second++) { if (second >= 60) Assert.fail("timeout"); try { if (driver.findElement(By.xpath("//div[@class='ui-dropdown-list']/div/ul/li[1]/div/div[1]")) .isDisplayed()) break; } catch (Exception ex) { } Util.sleep(1000); } String xpath1 = "//div[@class='ui-dropdown-list']/div/ul/li[1]/div/div[1]"; findElementByXpath(xpath1); // WebElement showAllCheckBox = driver.findElement(By.xpath("//div[@class='ui-dropdown-list']/div/ul/li[1]/div/div[1]")); // Util.printMessage("showAllCheckBox------"+showAllCheckBox); // driver.switchTo().activeElement(); // driver.findElement(By.xpath("//div[@class='ui-dropdown-list']/div/ul/li[1]/div/div[1]")).click(); Util.sleep(2000); String xpath2 = "//table[normalize-space(@class)='ui-cep-grid-table table table-bordered']"; findElementByXpath(xpath2); // WebElement webElement = driver.findElement(By.xpath("//table[normalize-space(@class)='ui-cep-grid-table table table-striped table-bordered']")); // Util.printMessage("webElement------"+webElement); List<String> actualTableHeaders = homePage.getTableRow("assetReportDataTable", 0, true); assertEquals(actualTableHeaders.size(), expectedTableHeaders.size()); for (int i = 0; i < actualTableHeaders.size(); i++) assertEquals(actualTableHeaders.get(i), expectedTableHeaders.get(i)); }
From source file:cepfrontend.TestVerifyReportHeadersWithLanguage.java
@Test public void TEST_ReportHeadersWithOutSupport() throws Exception { ArrayList<String> tableHeadersWithLanguage = new ArrayList<String>( Arrays.asList("Product", "Release", "Seats", "Serial # / Product Key", "License Type", "Language", "Subscription", "Support", "Subscription End Date")); loginAsCEPUser();/*w w w . jav a 2 s .c om*/ CEP cep = utilCreateSubscriptionRenewal(); loginPage = cep.getLoginPage(); homePage = cep.getHomePage(); mainWindow.select(); Util.sleep(5000); //Clicking on the Display drop down button String xpath = "//div[@class='ui-dropdown-header']/div"; findElementByXpath(xpath); // WebElement webElement1 = driver.findElement(By.xpath("//div[@class='ui-dropdown-header']/div")); // Util.sleep(3000); // Util.printMessage("webElement------"+webElement1); // driver.switchTo().activeElement(); // driver.findElement(By.xpath("//div[@class='ui-dropdown-header']/div")).click(); Util.sleep(5000); //Clicking on the language check box in Display drop down button for (int second = 0;; second++) { if (second >= 60) Assert.fail("timeout"); try { if (driver.findElement(By.xpath("//div[@class='ui-dropdown-list']/div/ul/li[6]/div/div[1]")) .isDisplayed()) break; } catch (Exception ex) { } Util.sleep(1000); } String xpath1 = "//div[@class='ui-dropdown-list']/div/ul/li[6]/div/div[1]"; findElementByXpath(xpath1); // WebElement support = driver.findElement(By.xpath("//div[@class='ui-dropdown-list']/div/ul/li[6]/div/div[1]")); // Util.printMessage("support------"+support); // driver.switchTo().activeElement(); // driver.findElement(By.xpath("//div[@class='ui-dropdown-list']/div/ul/li[6]/div/div[1]")).click(); Util.sleep(2000); String xpath2 = "//table[normalize-space(@class)='ui-cep-grid-table table table-bordered']"; findElementByXpath(xpath2); // WebElement webElementTable = driver.findElement(By.xpath("//table[normalize-space(@class)='ui-cep-grid-table table table-striped table-bordered']")); // Util.printMessage("webElementTable------"+webElementTable); List<String> tableHeadersAfterLanguageSelect = new ArrayList<>(); tableHeadersAfterLanguageSelect = homePage.getTableRow("assetReportDataTable", 0, true); assertEquals(tableHeadersAfterLanguageSelect.size(), tableHeadersWithLanguage.size()); for (int i = 0; i < tableHeadersAfterLanguageSelect.size(); i++) assertEquals(tableHeadersAfterLanguageSelect.get(i), tableHeadersWithLanguage.get(i)); }
From source file:cepfrontend.TestVerifyReportHeadersWithOutSupport.java
@Test public void TEST_ReportHeadersWithOutSupport() throws Exception { ArrayList<String> tableHeadersWithSupport = new ArrayList<String>( Arrays.asList("Product", "Release", "Seats", "Serial # / Product Key", "License Type", "Subscription", "Support", "Subscription End Date")); ArrayList<String> tableHeadersWithOutSupport = new ArrayList<String>(Arrays.asList("Product", "Release", "Seats", "Serial # / Product Key", "License Type", "Subscription", "Subscription End Date")); loginAsCEPUser();/*from www. j a va 2 s. c om*/ CEP cep = utilCreateSubscriptionRenewal(); loginPage = cep.getLoginPage(); homePage = cep.getHomePage(); mainWindow.select(); String xpath = "//table[normalize-space(@class)='ui-cep-grid-table table table-bordered']"; findElementByXpath(xpath); // WebElement webElement = driver.findElement(By.xpath("//table[normalize-space(@class)='ui-cep-grid-table table table-striped table-bordered']")); // Util.printMessage("webElement------"+webElement); List<String> actualTableHeaders = homePage.getTableRow("assetReportDataTable", 0, true); assertEquals(actualTableHeaders.size(), tableHeadersWithSupport.size()); for (int i = 0; i < actualTableHeaders.size(); i++) assertEquals(actualTableHeaders.get(i), tableHeadersWithSupport.get(i)); Util.sleep(5000); //Clicking on the Display drop down button String xpath1 = "//div[@class='ui-dropdown-header']/div"; findElementByXpath(xpath1); Util.sleep(5000); //Clicking on the support check box in Display drop down button for (int second = 0;; second++) { if (second >= 60) Assert.fail("timeout"); try { if (driver.findElement(By.xpath("//div[@class='ui-dropdown-list']/div/ul/li[9]/div/div[1]")) .isDisplayed()) break; } catch (Exception ex) { } Util.sleep(1000); } String xpath2 = "//div[@class='ui-dropdown-list']/div/ul/li[9]/div/div[1]"; findElementByXpath(xpath2); Util.sleep(2000); findElementByXpath(xpath); // WebElement webElementTable = driver.findElement(By.xpath("//table[normalize-space(@class)='ui-cep-grid-table table table-striped table-bordered']")); // Util.printMessage("webElementTable------"+webElementTable); List<String> tableHeadersAfterSupportUnSelect = new ArrayList<>(); tableHeadersAfterSupportUnSelect = homePage.getTableRow("assetReportDataTable", 0, true); if (tableHeadersAfterSupportUnSelect.get(6).equalsIgnoreCase("")) tableHeadersAfterSupportUnSelect.remove(6); assertEquals(tableHeadersAfterSupportUnSelect.size(), tableHeadersWithOutSupport.size()); for (int i = 0; i < tableHeadersAfterSupportUnSelect.size(); i++) assertEquals(tableHeadersAfterSupportUnSelect.get(i), tableHeadersWithOutSupport.get(i)); }
From source file:CertMaven.pageObjects.DriverPage.java
public DriverPage enterDetails() throws InterruptedException { driver.findElement(By.xpath("//input[@class='rf-cal-inp empty-or-date ']")).clear(); Thread.sleep(2000);//from www.j a v a 2s .c om driver.findElement(By.xpath("//input[@class='rf-cal-inp empty-or-date ']")).click(); Thread.sleep(2000); driver.findElement(By.xpath("//input[@class='rf-cal-inp empty-or-date ']")).sendKeys("02/18/1956"); driver.findElement(By.xpath("//input[@class='valid']")).clear(); driver.findElement(By.xpath("//input[@class='valid']")).sendKeys("B13848967"); driver.findElement( By.xpath("//input[@id='policyDataGatherForm:driverMVOInformation_driver_firstLicenseAge']")) .clear(); driver.findElement( By.xpath("//input[@id='policyDataGatherForm:driverMVOInformation_driver_firstLicenseAge']")) .sendKeys("22"); return new DriverPage(driver); }
From source file:ch.admin.isb.hermes5.common.AbstractPageDriver.java
License:Apache License
public WebElement findElementByXpath(String xpath) { return driver.findElement(By.xpath(xpath)); }
From source file:ch.admin.isb.hermes5.common.AbstractPageDriver.java
License:Apache License
public List<WebElement> findElementsByXpath(String xpath) { return driver.findElements(By.xpath(xpath)); }
From source file:ch.admin.isb.hermes5.common.AnwenderloesungPageDriver.java
License:Apache License
public AnwenderloesungPageDriver clickNext() { findElement(By.xpath("//input[@value='Weiter']")).click(); return this; }
From source file:ch.hearc.arcgames.tests.searchTest.java
@Test public void loggedUserTryAccessPages() throws Exception { // Non-admin user login informations String username = "nonAdmin"; String passwd = "nonAdminPassword"; // We open the web app driver.get(baseUrl + "/ArcGames/"); // SignUp with a test user String pattern = "fake"; signUp(pattern, pattern, pattern, pattern, pattern, pattern); // Login as non-admin login(username, passwd);// w ww .ja va 2s . c o m // Go to users page driver.findElement(By.linkText("Users")).click(); // Search user that matches "fake" pattern simpleSearch(pattern); // Check results String result = driver.findElement(By.xpath("//form[@id='j_idt21']/table/tbody[2]/tr/td")).getText(); assertTrue(result.contains(pattern)); // Search user that matches "fake" user advancedSearch(pattern); // Check results result = driver.findElement(By.xpath("//form[@id='j_idt21']/table/tbody[2]/tr/td")).getText(); assertTrue(result.contains(pattern)); // Logout driver.findElement(By.linkText("logout")).click(); }
From source file:ch.vorburger.mifos.wiki.ZWikiScraper.java
License:Apache License
private List<WikiNode> ulToNodes(WebElement subElements, WikiNode parent) { List<WikiNode> nodes = new LinkedList<ZWikiScraper.WikiNode>(); List<WebElement> lis = subElements.findElements(By.xpath("li")); for (WebElement li : lis) { WebElement ahref = li.findElement(By.tagName("span")).findElement(By.tagName("a")); String href = ahref.getAttribute("href"); String pageID = wikiURL2PageId(href); WikiNode n = new WikiNode(); n.pageID = pageID;//from w w w . ja v a2 s .co m n.parentNode = parent; try { WebElement ul = li.findElement(By.tagName("ul")); n.childNodes.addAll(ulToNodes(ul, n)); } catch (NoSuchElementException e) { // No children then, OK. } nodes.add(n); } return nodes; }
From source file:ch.vorburger.vaadin.designer.tests.web.DesignerWebDriverTest.java
License:Apache License
@Test public void testChangeModelAssertFieldMovedInBrowser() throws Exception { screen.getFields().get(0).setX(44);// w w w . j a v a 2 s .c o m screen.getFields().get(0).setY(56); WebElement fieldToDrag = driver.findElement(By.id("name")); WebElement parentDIV = fieldToDrag.findElement(By.xpath("..")); assertEquals("44px", parentDIV.getCssValue("left")); assertEquals("56px", parentDIV.getCssValue("top")); }