List of usage examples for org.openqa.selenium WebDriver findElements
@Override List<WebElement> findElements(By by);
From source file:com.continuuity.test.TestUtil.java
License:Apache License
public Set<String> getTopList(WebDriver driver) { Set<String> topList = Sets.newHashSet(); for (WebElement element : driver.findElements(TYPES)) { topList.add(element.getAttribute(Constants.TEXT)); }// ww w . ja va 2s.c o m return topList; }
From source file:com.continuuity.test.TestUtil.java
License:Apache License
public Set<String> getTopListUri(WebDriver driver) { Set<String> topListUri = Sets.newHashSet(); for (WebElement element : driver.findElements(TYPES)) { topListUri.add(element.getAttribute(Constants.HREF)); }/*w ww. j a v a 2 s .com*/ return topListUri; }
From source file:com.davidgaskins.learningtounittest.Utilities.java
License:Apache License
public static WebElement getElement(WebDriver driver, String path) { WebElement result = null;// w ww . ja v a 2 s.co m try { List<WebElement> inputs = driver.findElements(By.xpath(path)); validateCorrectSize(inputs); result = inputs.get(0); } catch (MoreElementsThanExpectedException me) { cleanUpSystem(me); } return result; }
From source file:com.deque.axe.AXE.java
License:Mozilla Public License
/** * Recursively find frames and inject a script into them. * @param driver An initialized WebDriver * @param script Script to inject/*from www . j a v a 2 s .c o m*/ * @param parents A list of all toplevel frames */ private static void injectIntoFrames(final WebDriver driver, final String script, final ArrayList<WebElement> parents) { final JavascriptExecutor js = (JavascriptExecutor) driver; final List<WebElement> frames = driver.findElements(By.tagName("iframe")); for (WebElement frame : frames) { driver.switchTo().defaultContent(); if (parents != null) { for (WebElement parent : parents) { driver.switchTo().frame(parent); } } driver.switchTo().frame(frame); js.executeScript(script); ArrayList<WebElement> localParents = (ArrayList<WebElement>) parents.clone(); localParents.add(frame); injectIntoFrames(driver, script, localParents); } }
From source file:com.DFATPageObjects.MyApplications.Step1_Personal_PageObjects.java
public boolean errorChecker(WebDriver Driver, String Path, String Section, int Errors) throws IOException, InterruptedException { try {/*from w w w . j a v a 2 s .c o m*/ int count = 0; click(SaveAndContinueButton); Thread.sleep(1000); List<WebElement> ErrorList = new ArrayList<WebElement>(); ErrorList = Driver.findElements(By.xpath("//span[contains(@id,'-error')]")); BaseClass.myWriteAppend(Path, ""); BaseClass.myWriteAppend(Path, Section); BaseClass.myWriteAppend(Path, ""); //System.out.println("Error Message list"); for (WebElement errrors : ErrorList) { if (!errrors.getText().isEmpty()) { BaseClass.myWriteAppend(Path, "Error Text " + (count + 1) + ":" + errrors.getText()); //System.out.println("Error Text "+(count+1)+":"+errrors.getText()); count = count + 1; } } System.out.println("Expected " + Errors + " Errors and Found " + count); BaseClass.myWriteAppend(Path, ""); BaseClass.myWriteAppend(Path, "Expected " + Errors + " Errors and Found " + count); if (!(count == Errors)) { System.out.println("Number of error Messages Inconsistant."); return false; } BaseClass.myWriteAppend(Path, "***********************************"); BaseClass.myWriteAppend(Path, ""); return true; } catch (Exception e) { return false; } }
From source file:com.ecofactor.qa.automation.insite.page.RoleManagementImpl.java
License:Open Source License
/** * <p>/*from w ww . j a v a2s .c o m*/ * Verify the Search is populated with the value included in the textField. * </p> * @param driver the driver * @param searchResultValue the search result value * @return boolean */ private boolean confirmSearchResultValue(final WebDriver driver, final String searchResultValue) { DriverConfig.setLogString("Confirm Serach result as " + searchResultValue, true); boolean outcome = false; DriverConfig.setLogString("check if multiple results are displayed.", true); isMultipleClassNameDisplayed(driver, roleConfig.get(SEARCH_RESULT_CLASS), MEDIUM_TIMEOUT); final List<WebElement> resultElements = driver .findElements(By.className(roleConfig.get(SEARCH_RESULT_CLASS))); DriverConfig.setLogString("check if results displayed are relevent to provided search value.", true); for (final WebElement webElement : resultElements) { outcome = webElement.getText().contains(searchResultValue) ? true : false; DriverConfig.setLogString("Displayed Result." + searchResultValue, true); if (outcome) { return outcome; } } DriverConfig.setLogString("check if results are displayed.", true); Assert.assertEquals(true, resultElements.size() > 0, "Result size is zero"); return outcome; }
From source file:com.ecofactor.qa.automation.platform.util.Pageutil.java
License:Open Source License
/** * Checks if is displayed by list.// w w w .j a va2 s . co m * @param driver the driver * @param locator the locator * @param timeout the timeout * @return true, if is displayed by list */ public static boolean isDisplayedByList(final WebDriver driver, final By locator, final CustomTimeout timeout) { boolean isLoaded = false; try { isLoaded = new WebDriverWait(driver, timeout.getValue()).until(new ExpectedCondition<Boolean>() { public Boolean apply(final WebDriver driver) { final List<WebElement> elements = driver.findElements(locator); boolean displayed = false; for (final WebElement element : elements) { displayed = element.isDisplayed(); if (displayed) { break; } } return displayed; } }); } catch (TimeoutException te) { isLoaded = false; } return isLoaded; }
From source file:com.ecofactor.qa.automation.platform.util.Pageutil.java
License:Open Source License
/** * Get the list of elements.//from www . ja v a 2 s. c om * @param driver the driver * @param locator the locator * @param timeout the timeout * @return the elements */ public static List<WebElement> getElements(final WebDriver driver, final By locator, final CustomTimeout timeout) { return new WebDriverWait(driver, timeout.getValue()).until(new ExpectedCondition<List<WebElement>>() { public List<WebElement> apply(final WebDriver driver) { return driver.findElements(locator); } }); }
From source file:com.ecofactor.qa.automation.util.mail.Gmail.java
License:Open Source License
/** * Delete first mail.// ww w . j av a 2 s . co m * @param driver the driver */ public void deleteFirstMail(WebDriver driver) { DriverConfig.setLogString("Delete First Mail", true); DriverConfig.setLogString("Click Inbox", true); WebElement inboxElement = DriverConfig.getDriver().findElement(By.partialLinkText("Inbox")); inboxElement.click(); mediumWait(); DriverConfig.setLogString("Click Subject of Email.", true); boolean subjectDisplayed = isDisplayedByCSS(driver, ".ae4.UI.UJ", MEDIUM_TIMEOUT); if (subjectDisplayed) { WebElement webElement1 = driver.findElement(By.cssSelector(".ae4.UI.UJ")); if (!webElement1.getText().contains("No new mail")) { WebElement firstElement2 = null; if (webElement1 != null && webElement1.findElements(By.tagName(TAG_BOLD)) != null && webElement1.findElements(By.tagName(TAG_BOLD)).size() > 0) { firstElement2 = webElement1.findElements(By.tagName(TAG_BOLD)).get(0); } else { firstElement2 = webElement1.findElements(By.cssSelector("td.yX.xY")).get(0); } if (firstElement2 != null && firstElement2.isDisplayed()) { firstElement2.click(); mediumWait(); DriverConfig.setLogString("Delete the Email", true); if (driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) != null && driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")).size() == 2) { DriverConfig.setLogString("Click delete old mails", true); WebElement webElement2 = driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) .get(1); webElement2.click(); } else { DriverConfig.setLogString("Click delete old mails", true); smallWait(); WebElement webElement2 = driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) .get(1); webElement2.click(); } smallWait(); } } } }
From source file:com.ecofactor.qa.automation.util.mail.GmailForNewUser.java
License:Open Source License
/** * Delete first mail.// ww w . j a v a 2 s. c om * @param driver the driver */ public void deleteFirstMail(WebDriver driver) { DriverConfig.setLogString("Delete First Mail", true); DriverConfig.setLogString("Click Inbox", true); WebElement inboxElement = driver.findElement(By.partialLinkText("Inbox")); inboxElement.click(); mediumWait(); DriverConfig.setLogString("Click Subject of Email.", true); // boolean subjectDisplayed=isDisplayedByTagName(driver, TAG_BOLD, MEDIUM_TIMEOUT); boolean subjectDisplayed = isDisplayedByCSS(driver, ".ae4.UI.UJ", MEDIUM_TIMEOUT); if (subjectDisplayed) { WebElement webElement1 = driver.findElement(By.cssSelector(".ae4.UI.UJ")); // WebElement webElement1 = driver.findElement(By.xpath(".//*[span]")); if (!webElement1.getText().contains("No new mail")) { WebElement firstElement2 = null; if (webElement1 != null && webElement1.findElements(By.tagName(TAG_BOLD)) != null && webElement1.findElements(By.tagName(TAG_BOLD)).size() > 0) { firstElement2 = webElement1.findElements(By.tagName(TAG_BOLD)).get(0); } else { firstElement2 = webElement1.findElements(By.cssSelector("td.yX.xY")).get(0); } if (firstElement2 != null && firstElement2.isDisplayed()) { firstElement2.click(); mediumWait(); DriverConfig.setLogString("Delete the Email", true); if (driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) != null && driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")).size() == 2) { DriverConfig.setLogString("Click delete old mails", true); WebElement webElement2 = driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) .get(1); webElement2.click(); } else { DriverConfig.setLogString("Click delete old mails", true); smallWait(); WebElement webElement2 = driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) .get(1); webElement2.click(); } smallWait(); } } } }