default ExpectedCondition<List<WebElement>> PRESENCES(By by) { return ExpectedConditions.presenceOfAllElementsLocatedBy(by); }
@Override public List<WebElement> findElements(By by) { try { return fluentWait.until(presenceOfAllElementsLocatedBy(by)); } catch (Exception e) { LOGGER.error(e.getMessage()); throw e; } }
/** * Waits during {@code timeout} until all {@link WebElement} with provided {@code elementsLocator} * is attached to DOM. * * <p>Note! It does not mean that elements are visible. * * @param elementsLocator common locator for multiple elements * @param timeout waiting timeout in seconds * @return all found elements */ public List<WebElement> waitPresenceOfAllElements(By elementsLocator, int timeout) { return webDriverWaitFactory.get(timeout).until(presenceOfAllElementsLocatedBy(elementsLocator)); }
@Override public List<WebElement> findElements(By by) { clearElementList(); List<WebElement> elements = null; try { elements = waitingAction.waitUntil(ExpectedConditions.presenceOfAllElementsLocatedBy(by)); } catch (Exception e) { logger.error("Element Not Found By={}", by.toString(), e); } return elements; }
@SafeVarargs public final <R> R waitAnd(Function<By, R> andThen, By by, Function<By, ExpectedCondition<?>>... conditions) { WebDriverWait wait = new WebDriverWait(getDelegate(), timeout); ExpectedCondition<?> cond; if (conditions == null || conditions.length == 0) { cond = ExpectedConditions.presenceOfAllElementsLocatedBy(by); } else { cond = conditions.length == 1 ? conditions[0].apply(by) : ExpectedConditions.and(MCRExpectedConditions.combine(by, conditions)); } wait.until(cond); return andThen.apply(by); }
private List<WebElement> doFindElements() { if (timeout > 0) { return new WebDriverWait(webDriver, timeout) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)); } else { return webDriver.findElements(by); } }
@Override public List<WebElement> findElements(String locator) { WebDriverWait wait = new WebDriverWait(driver, SteviaContext.getWaitForElement(),THREAD_SLEEP); return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(determineLocator(locator))); }
public void isOptionFromRadioButtonGroupSelected(String accessType,String by,String option,String accessName,boolean shouldBeSelected) throws TestCaseFailed { List<WebElement> radioButtonGroup = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(getelementbytype(accessType, accessName))); for (WebElement rb : radioButtonGroup) { if(by.equals("value")) { if(rb.getAttribute("value").equals(option)) { if((!rb.isSelected()) && shouldBeSelected) throw new TestCaseFailed("Radio Button not selected"); else if(rb.isSelected() && !shouldBeSelected) throw new TestCaseFailed("Radio Button is selected"); } } else if(rb.getText().equals(option)) { if((!rb.isSelected()) && shouldBeSelected) throw new TestCaseFailed("Radio Button not selected"); else if(rb.isSelected() && !shouldBeSelected) throw new TestCaseFailed("Radio Button is selected"); } } }
/** * @author wasiq.bhamla * @since Jan 30, 2018 7:33:47 PM * @param locator * @param waitStrategy */ private void wait (final By locator, final WaitStrategy waitStrategy) { switch (waitStrategy) { case ENABLED: this.wait.until (ExpectedConditions.elementToBeClickable (locator)); break; case PRESENT: this.wait.until (ExpectedConditions.presenceOfAllElementsLocatedBy (locator)); break; case VISIBLE: this.wait.until (visibilityOfAllElementsLocatedBy (locator)); break; case NONE: default: break; } } }