List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfAllElementsLocatedBy
public static ExpectedCondition<List<WebElement>> presenceOfAllElementsLocatedBy(final By locator)
From source file:applicationdriverlayer.pageobjects.squash.booking.CourtAndTimeSlotChooserPage.java
License:Apache License
@Override protected void waitForLoadToComplete() { new WebDriverWait(driver, explicitWaitTimeoutSeconds) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("booking-table"))); new WebDriverWait(driver, explicitWaitTimeoutSeconds).until(ExpectedConditions.visibilityOf(dateDropdown)); }
From source file:br.ufmg.dcc.saotome.beholder.selenium.ui.SeleniumComponent.java
License:Apache License
@Override public <T extends Component, Y extends T> List<T> loadByAttribute(Class<Y> type, final String IdFather, final String tagName, final String attributeName, final String value) { List<T> components = new ArrayList<T>(); this.locator = new Locator(tagName, attributeName, value); if (this.isDisplayed) { WebDriverWait wait = new WebDriverWait(getSeleniumWebDriver(), TIMEOUT); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.tagName(tagName))); List<WebElement> elements; if (IdFather == null) { elements = getSeleniumWebDriver().findElements(By.tagName(tagName)); } else {/*from www. ja va 2s . c o m*/ elements = getSeleniumWebDriver().findElement(By.id(IdFather)).findElements(By.tagName(tagName)); } for (WebElement el : elements) { if ((el.getAttribute(attributeName) != null) && (el.getAttribute(attributeName).equalsIgnoreCase(value))) { T sc = null; try { // Use of reflection for instantiate sc // this equivalent the get an instance of Builder.uiComponentBuilderInstance() sc = (T) type.getDeclaredConstructor(WebDriver.class).newInstance(getSeleniumWebDriver()); } catch (Exception e) { e.printStackTrace(); } ((SeleniumComponent) sc).setAttribute(attributeName, value); ((SeleniumComponent) sc).setElement(el); components.add(sc); } } } return components; }
From source file:com.arcbees.test.ElementLocator.java
License:Apache License
private List<WebElement> doFindElements() { if (timeout > 0) { return new WebDriverWait(webDriver, timeout) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)); } else {/*from w ww.jav a 2 s. c om*/ return webDriver.findElements(by); } }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to find presence of the elements in page. * //from w ww . ja va 2s . c om * @param by * (by element to be visible in page) * @param timeoutInSeconds * (timeout value in seconds) * @return presenceOfElement (Web element object of the presence element) */ public List<WebElement> findPresenceOfElements(final By by, final int timeoutInSeconds) { List<WebElement> presenceOfElements; try { presenceOfElements = (new WebDriverWait(this.driver, timeoutInSeconds)) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)); } catch (Exception e) { String errorMessage = "Could not find presence of elements: " + by.toString(); this.logger.logWithScreenShot("Could not find presence of elements: ", this.driver); throw new RuntimeException(errorMessage); } return presenceOfElements; }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to return list of titles/get text for the given xpath. * * @param xpath//from ww w. j av a 2 s . c o m * (xpath of elements) * @return List<String> list of titles of WebElements */ public List<String> getListOfTitlesForElementsWithGivenXPath(final String xpath) { this.logger.log("To get list of existing elements having xpath : " + xpath); List<String> listOfWebElementTitle = new ArrayList<String>(); List<WebElement> listOfElements = (new WebDriverWait(this.driver, 30)) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(xpath))); for (WebElement element : listOfElements) { if (element.getText() != null && element.getText().length() > 0) { listOfWebElementTitle.add(element.getText()); } } return listOfWebElementTitle; }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Gets the elements.//from w w w . j a va2 s .c o m * * @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 Timeout timeout) { try { return new WebDriverWait(driver, timeout.getValue()) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(locator)); } catch (Exception ex) { return null; } }
From source file:com.cognifide.qa.bb.aem.dialog.classic.field.AemDropdown.java
License:Apache License
/** * Clicks the item in the dropdown list. Item is identified by the provided index. First item has * index 0.//from w ww. ja v a 2s .c om * * @param index starts from 0 * @return this Aem dropdown object */ public AemDropdown selectByIndex(int index) { expandDropdown(); List<WebElement> items = bobcatWait.withTimeout(Timeouts.MEDIUM) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector(ITEMS_LOCATOR))); items.get(index).click(); return this; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is displayed by css class name. * @param driver the driver//from w w w. j a va2 s . c o m * @param fieldname the fieldname * @param textValue the text value * @param textValue2 the text value2 * @param timeOut the time out * @return boolean */ public static boolean isDisplayedByClassNameForWeeklySchedule(final WebDriver driver, final String fieldname, final String textValue, final String textValue2, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean outcome = false; WebDriverWait wait = new WebDriverWait(driver, timeOut); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className(fieldname))); WebElement element = d.findElement(By.className(fieldname)); if (element.getText().contains(textValue) || element.getText().contains(textValue2)) { outcome = true; } return outcome; } }); return isLoaded; }
From source file:com.fullteaching.backend.e2e.FullTeachingTestE2ESleep.java
License:Apache License
@Test @DisplayName("Test video session") void oneToOneVideoAudioSessionChrome() throws Exception { // TEACHER// w w w . ja v a 2 s . c om final String userEmail = "teacher@gmail.com"; final String userPass = "pass"; this.user = setupBrowser("chrome"); log.info("Test video session"); this.login(user, userEmail, userPass); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getWaiter().until(ExpectedConditions.presenceOfElementLocated( By.cssSelector(("ul.collection li.collection-item:first-child div.course-title")))); user.getDriver() .findElement(By.cssSelector("ul.collection li.collection-item:first-child div.course-title")) .click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getWaiter().until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("#md-tab-label-0-1")))); user.getDriver().findElement(By.cssSelector("#md-tab-label-0-1")).click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getDriver().findElement(By.cssSelector("ul div:first-child li.session-data div.session-ready")) .click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getWaiter() .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("div.participant video")))); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } checkVideoPlaying(user, user.getDriver().findElement(By.cssSelector(("div.participant video"))), "div.participant"); // STUDENT BrowserUser student = setupBrowser("chrome"); login(student, "student1@gmail.com", "pass"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } student.getWaiter().until(ExpectedConditions.presenceOfElementLocated( By.cssSelector(("ul.collection li.collection-item:first-child div.course-title")))); student.getDriver() .findElement(By.cssSelector("ul.collection li.collection-item:first-child div.course-title")) .click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } student.getWaiter() .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("#md-tab-label-0-1")))); student.getDriver().findElement(By.cssSelector("#md-tab-label-0-1")).click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } student.getDriver().findElement(By.cssSelector("ul div:first-child li.session-data div.session-ready")) .click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } student.getWaiter() .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("div.participant video")))); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } checkVideoPlaying(student, student.getDriver().findElement(By.cssSelector(("div.participant video"))), "div.participant"); // Student ask for intervention student.getWaiter().until(ExpectedConditions.elementToBeClickable( By.xpath("//div[@id='div-header-buttons']//i[text() = 'record_voice_over']"))); student.getDriver() .findElement(By.xpath("//div[@id='div-header-buttons']//i[text() = 'record_voice_over']")).click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } // Teacher accepts intervention user.getWaiter() .until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(@class, 'usr-btn')]"))); user.getDriver().findElement(By.xpath("//a[contains(@class, 'usr-btn')]")).click(); // Check both videos student.getWaiter().until( ExpectedConditions.presenceOfElementLocated(By.cssSelector(("div.participant-small video")))); checkVideoPlaying(student, student.getDriver().findElement(By.cssSelector(("div.participant-small video"))), "div.participant-small"); checkVideoPlaying(student, student.getDriver().findElement(By.cssSelector(("div.participant-small video"))), "div.participant-small"); user.getWaiter().until( ExpectedConditions.presenceOfElementLocated(By.cssSelector(("div.participant-small video")))); checkVideoPlaying(user, user.getDriver().findElement(By.cssSelector(("div.participant-small video"))), "div.participant-small"); checkVideoPlaying(user, user.getDriver().findElement(By.cssSelector(("div.participant-small video"))), "div.participant-small"); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } // Teacher removes user user.getWaiter() .until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(@class, 'usr-btn')]"))); user.getDriver().findElement(By.xpath("//a[contains(@class, 'usr-btn')]")).click(); // Wait until only one video user.getWaiter().until(ExpectedConditions.not(ExpectedConditions .presenceOfAllElementsLocatedBy(By.cssSelector(("div.participant-small video"))))); student.getWaiter().until(ExpectedConditions.not(ExpectedConditions .presenceOfAllElementsLocatedBy(By.cssSelector(("div.participant-small video"))))); try { Thread.sleep(4000); } catch (InterruptedException e) { e.printStackTrace(); } // Logout student this.logut(student); student.dispose(); }
From source file:com.ggasoftware.uitest.control.Elements.java
License:Open Source License
/** * Wait until all elements exist.//from w w w. jav a 2s .c o m * * @param timeoutSec seconds to wait until all elements exist * @param checkCondition log assert for expected conditions. * @return Parent instance */ public ParentPanel waitForAllElementsExist(final int timeoutSec, final boolean checkCondition) { logAction(this, getParentClassName(), format("waitForAllElementsExist: %s", locator)); boolean exist; long start = System.currentTimeMillis() / 1000; WebDriverWait wait = (WebDriverWait) new WebDriverWait(getDriver(), timeoutSec) .ignoring(StaleElementReferenceException.class); setTimeout(1); try { wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(bylocator)); exist = true; } catch (TimeoutException e) { logTechnical(format("waitForAllElementsExist: [ %s ] during: [ %d ] sec ", locator, System.currentTimeMillis() / 1000 - start)); exist = false; } setTimeout(TIMEOUT); if (checkCondition) { ReporterNGExt.logAssertTrue(ReporterNGExt.BUSINESS_LEVEL, exist, format("waitForAllElementsExist - all elements of '%s' should exist", name), TestBaseWebDriver.takePassedScreenshot); } return parent; }