selenium 显示等待实例 org.openqa.selenium.support.ui.FluentWait

原文链接: https://www.programcreek.com/java-api-examples/index.php?api=org.openqa.selenium.support.ui.FluentWait

Example 1

Project: easycukes   File: SeleniumHelper.java   View source code7 votesvote downvote up
/**
 * @param by
 * @return
 */
public static void waitUntilValueIsSelected(@NonNull final WebDriver driver,
                                            @NonNull final By by, @NonNull final String value) {
    final FluentWait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);
    wait.until(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver webDriver) {
            try {
                final WebElement webElement = webDriver.findElement(by);
                new Select(webElement).selectByValue(value);
                return webElement.getAttribute("value").equals(value);
            } catch (final StaleElementReferenceException e) {
                return false;
            }
        }
    });
}
 

 

Example 2

Project: POM_HYBRID_FRAMEOWRK   File: WebUtilities.java   View source code6 votesvote downvote up
/**
 * Wait for element to appear.
 *
 * @param driver the driver
 * @param element the element
 * @param logger the logger
 */
public static boolean waitForElementToAppear(WebDriver driver, WebElement element, ExtentTest logger) {
	boolean webElementPresence = false;
	try {
		Wait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver).pollingEvery(2, TimeUnit.SECONDS)
				.withTimeout(60, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
		fluentWait.until(ExpectedConditions.visibilityOf(element));
		if (element.isDisplayed()) {
			webElementPresence= true;
		}
	} catch (TimeoutException toe) {
		logger.log(LogStatus.ERROR, "Timeout waiting for webelement to be present<br></br>" + toe.getStackTrace());
	} catch (Exception e) {
		logger.log(LogStatus.ERROR, "Exception occured<br></br>" + e.getStackTrace());
	}
	return webElementPresence;
}
 

 

Example 3

Project: WebAutomation_AllureParallel   File: FluentWaiting.java   View source code6 votesvote downvote up
public static void waitUntillElementToBeClickable(int TotalTimeInSeconds, int PollingTimeInMilliseconds, WebElement Element)
{
	 FluentWait<WebDriver> ClickableWait = new FluentWait<WebDriver>(getWebDriver())
	            .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
	            .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
	            .ignoring(NoSuchElementException.class);
	 
	 ClickableWait.until(ExpectedConditions.elementToBeClickable(Element));
}
 

Example 4

Project: Quantum   File: AppiumUtils.java   View source code6 votesvote downvote up
private static MobileElement fluentWait(AppiumDriver driver, By xpath) {
    MobileElement waitElement = null;

    FluentWait<RemoteWebDriver> fwait = new FluentWait<RemoteWebDriver>(driver).withTimeout(15, TimeUnit.SECONDS)
            .pollingEvery(500, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class)
            .ignoring(TimeoutException.class);

    try {
        waitElement = (MobileElement) fwait.until(new Function<RemoteWebDriver, WebElement>() {
            public WebElement apply(RemoteWebDriver driver) {
                return driver.findElement(xpath);
            }
        });
    } catch (Exception e) {
    }
    return waitElement;
}
 

Example 5

Project: menggeqa   File: AppiumElementLocator.java   View source code6 votesvote downvote up
private List<WebElement> waitFor() {
    // When we use complex By strategies (like ChainedBy or ByAll)
    // there are some problems (StaleElementReferenceException, implicitly
    // wait time out
    // for each chain By section, etc)
    try {
        changeImplicitlyWaitTimeOut(0, TimeUnit.SECONDS);
        FluentWait<By> wait = new FluentWait<>(by);
        wait.withTimeout(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
        return wait.until(waitingFunction);
    } catch (TimeoutException e) {
        return new ArrayList<>();
    } finally {
        changeImplicitlyWaitTimeOut(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
    }
}
 

Example 6

Project: che   File: TestWebElementRenderChecker.java   View source code6 votesvote downvote up
private void waitElementIsStatic(FluentWait<WebDriver> webDriverWait, WebElement webElement) {
  AtomicInteger sizeHashCode = new AtomicInteger();

  webDriverWait.until(
      (ExpectedCondition<Boolean>)
          driver -> {
            Dimension newDimension = waitAndGetWebElement(webElement).getSize();

            if (dimensionsAreEquivalent(sizeHashCode, newDimension)) {
              return true;
            } else {
              sizeHashCode.set(getSizeHashCode(newDimension));
              return false;
            }
          });
}
 

 

Example 7

Project: NYU-Bobst-Library-Reservation-Automator-Java   File: RunAutomator.java   View source code6 votesvote downvote up
/**
 * The wrapper for the actual run automator
 * @param browser The current browser for this run
 * @param user The current user for this run
 * @param offset The current amount of offsets (occurs when a time is already selected, but user is good)
 * @param setup The current setup containing all settings, loggers, and user pools
 * @throws CompletedException
 * @throws TimeSlotTakenException
 * @throws InterruptedException
 * @throws UserNumberException
 * @throws ReservationException
 * @throws InvalidLoginException
 */
public static void run(WebDriver browser, User user, int offset, Setup setup)
        throws CompletedException, TimeSlotTakenException, InterruptedException, UserNumberException,
        ReservationException, InvalidLoginException, NotConnectedException
{
    // Defines the wait
    FluentWait<WebDriver> wait = new FluentWait<>(browser)
            .withTimeout(20, TimeUnit.SECONDS)
            .pollingEvery(500, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);

    // Steps through each run component
    initiate(browser, wait);
    login(browser, user);
    setDate(browser, wait, setup.getSettings());
    TimeTuple timeTuple = setTime(browser, offset, setup.getUserPool(), setup.getSettings());
    selectRoom(browser, user, wait, setup.getSettings());
    updateLog(user, setup.getUserPool(), timeTuple);
}
 

Example 8

Project: redsniff   File: RedsniffWebDriverTester.java   View source code6 votesvote downvote up
/**
    * Wait until the supplied {@link FindingExpectation} becomes satisfied, or throw a {@link TimeoutException}
    * , using the supplied {@link FluentWait} 
    * This should only be done using a wait obtained by calling {@link #waiting()} to ensure the correct arguments are passed.
    * 
    * @param expectation
    * @param wait
    * @return
    */
public <T, E, Q extends TypedQuantity<E, T>> T waitFor(
		 final FindingExpectation<E, Q, SearchContext> expectation,	FluentWait<WebDriver> wait) {
	try {
		return new Waiter(wait).waitFor(expectation);
	}
	catch(FindingExpectationTimeoutException e){
		//do a final check to get the message unoptimized
		ExpectationCheckResult<E, Q> resultOfChecking = checker.resultOfChecking(expectation);
		String reason;
		if(resultOfChecking.meetsExpectation())
			reason = "Expectation met only just after timeout.  At timeout was:\n" + e.getReason();
		else {
			reason = resultOfChecking.toString();
			//if still not found first check there isn't a page error or something
			defaultingChecker().assertNoUltimateCauseWhile(newDescription().appendText("expecting ").appendDescriptionOf(expectation));
		}
		throw new FindingExpectationTimeoutException(e.getOriginalMessage(), reason, e);
	}
}
 

Example 9

Project: easycukes   File: SeleniumHelper.java   View source code6 votesvote downvote up
/**
 * @param driver
 * @param by
 * @return
 */
public static WebElement waitForElementToBePresent(@NonNull final WebDriver driver,
                                                   @NonNull final By by) {
    final FluentWait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);
    return wait.until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver webDriver) {
            try {
                if (webDriver.findElement(by).isDisplayed())
                    return webDriver.findElement(by);
                return null;
            } catch (final ElementNotVisibleException e) {
                return null;
            }
        }
    });
}
 

Example 10

Project: easycukes   File: SeleniumHelper.java   View source code6 votesvote downvote up
/**
 * @param text
 */
public static void waitUntilTextIsSelected(@NonNull final WebDriver driver,
                                           @NonNull final By by, @NonNull final String text) {
    final FluentWait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);

    wait.until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver webDriver) {
            final WebElement webElement = webDriver.findElement(by);
            new Select(webElement).selectByVisibleText(text);
            return webElement;
        }
    });
}
 

Example 11

Project: Testy   File: WebLocatorDriverExecutor.java   View source code6 votesvote downvote up
private WebElement doWaitElement(final WebLocator el, final long millis) {
    Wait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(millis, TimeUnit.MILLISECONDS)
            .pollingEvery(1, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class)
            .ignoring(ElementNotVisibleException.class)
            .ignoring(WebDriverException.class);

    try {
        if (el.getPathBuilder().isVisibility()) {
            el.currentElement = wait.until(ExpectedConditions.visibilityOfElementLocated(el.getSelector()));
        } else {
            el.currentElement = wait.until(d -> d.findElement(el.getSelector()));
        }
    } catch (TimeoutException e) {
        el.currentElement = null;
    }
    return el.currentElement;
}
 

Example 12

Project: carina   File: ToastDetector.java   View source code6 votesvote downvote up
private void waitForToast() {
    LOGGER.info("Wait for toast...");
    isPresent = false;
    FluentWait<WebDriver> fluentWait = new FluentWait<>(webDriver);
    fluentWait.withTimeout(waitTimeout, TimeUnit.SECONDS).pollingEvery(300, TimeUnit.MILLISECONDS).until(new Function<WebDriver, Boolean>() {
        @Override
        public Boolean apply(WebDriver input) {
            List<?> webElemenList = webDriver.findElements(By.xpath(String.format(TOAST_PATTERN, toastToWait)));
            if (webElemenList.size() == 1) {
                LOGGER.info("Toast with text present: " + toastToWait);
                isPresent = true;
                return true;
            } else {
                return false;
            }
        }
    });
}
 

Example 13

Project: carina   File: ExtendedWebElement.java   View source code6 votesvote downvote up
/**
 * is Element Not Present After Wait
 *
 * @param timeout in seconds
 * @return boolean - false if element still present after wait - otherwise true if it disappear
 */
public boolean isElementNotPresentAfterWait(final long timeout) {
    final ExtendedWebElement element = this;

    LOGGER.info(String.format("Check element %s not presence after wait.", element.getName()));

    Wait<WebDriver> wait =
            new FluentWait<WebDriver>(getDriver()).withTimeout(timeout, TimeUnit.SECONDS).pollingEvery(1,
                    TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
    try {
        return wait.until(driver -> {
            boolean result = driver.findElements(element.getBy()).isEmpty();
            if (!result) {
                LOGGER.info(String.format("Element '%s' is still present. Wait until it disappear.", element
                        .getNameWithLocator()));
            }
            return result;
        });
    } catch (Exception e) {
        LOGGER.error("Error happened: " + e.getMessage(), e.getCause());
        LOGGER.warn("Return standard element not presence method");
        return !element.isElementPresent();
    }
}
 

Example 14

Project: jwala   File: JwalaUi.java   View source code5 votesvote downvote up
public void testForBusyIcon(final int showTimeout, final int hideTimeout) {
    new FluentWait(driver).withTimeout(showTimeout, TimeUnit.SECONDS).pollingEvery(100, TimeUnit.MILLISECONDS)
            .until(ExpectedConditions.numberOfElementsToBe(
                    By.xpath("//div[contains(@class, 'AppBusyScreen') and contains(@class, 'show')]"), 1));
    // Please take note that when "display none" is re-inserted, the whitespace in between the attribute and the value is not there anymore e.g.
    // display: none => display:none hence the xpath => contains(@style,'display:none')
    new WebDriverWait(driver, hideTimeout)
            .until(ExpectedConditions.numberOfElementsToBe(
                    By.xpath("//div[contains(@class, 'AppBusyScreen') and contains(@class, 'show')]"), 0));
}
 

Example 15

Project: POM_HYBRID_FRAMEOWRK   File: WebUtilities.java   View source code5 votesvote downvote up
/**
 * Wait for element to disappear.
 *
 * @param driver the driver
 * @param element the element
 * @param logger the logger
 * @return true, if successful
 */
public static boolean waitForElementToDisappear(WebDriver driver, WebElement element, ExtentTest logger) {
	try {
		Wait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver).withTimeout(60, TimeUnit.SECONDS)
				.pollingEvery(2, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);

		fluentWait.until(ExpectedConditions.invisibilityOf(element));
		return true;
	} catch (Exception e) {
		logger.log(LogStatus.ERROR,
				"Error occured while waiting for element to disappear</br>" + e.getStackTrace());
		return false;
	}
}
 

Example 16

Project: POM_HYBRID_FRAMEOWRK   File: WebUtilities.java   View source code5 votesvote downvote up
/**
 * Wait for element staleness.
 *
 * @param driver the driver
 * @param element the element
 * @return true, if successful
 */
public static boolean waitForElementStaleness(WebDriver driver, WebElement element) {
	boolean staleStatus = new FluentWait<WebDriver>(driver)
			.withTimeout(60, TimeUnit.SECONDS)
			.pollingEvery(5, TimeUnit.SECONDS)
			.until(ExpectedConditions.stalenessOf(element));
	
	return staleStatus;
}
 

Example 17

Project: WebAutomation_AllureParallel   File: FluentWaiting.java   View source code5 votesvote downvote up
public static void waitUntillElementToBeSelected(int TotalTimeInSeconds, int PollingTimeInMilliseconds, WebElement Element)
{
	 FluentWait<WebDriver> SelectableWait = new FluentWait<WebDriver>(getWebDriver())
	            .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
	            .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
	            .ignoring(NoSuchElementException.class);
	 
	 SelectableWait.until(ExpectedConditions.elementToBeSelected(Element));
}
 

Example 18

Project: WebAutomation_AllureParallel   File: FluentWaiting.java   View source code5 votesvote downvote up
public static void waitUntillElementToBeVisible(int TotalTimeInSeconds, int PollingTimeInMilliseconds, WebElement Element)
{
	 FluentWait<WebDriver> visibleWait = new FluentWait<WebDriver>(getWebDriver())
	            .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
	            .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
	            .ignoring(NoSuchElementException.class);
	 
	 visibleWait.until(ExpectedConditions.visibilityOf(Element));
}
 

Example 19

Project: WebAutomation_AllureParallel   File: FluentWaiting.java   View source code5 votesvote downvote up
public static void waitUntillAlertWindowsPopUp(int TotalTimeInSeconds, int PollingTimeInMilliseconds)
{
	 FluentWait<WebDriver> alertWait = new FluentWait<WebDriver>(getWebDriver())
	            .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
	            .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
	            .ignoring(NoSuchElementException.class);
	 
	 alertWait.until(ExpectedConditions.alertIsPresent());
}
 

Example 20

Project: WebAutomation_AllureParallel   File: FluentWaiting.java   View source code5 votesvote downvote up
public static void waitUntillVisibilityOfElements(int TotalTimeInSeconds, int PollingTimeInMilliseconds, List<WebElement> Elements)
{
	 FluentWait<WebDriver> visibleWait = new FluentWait<WebDriver>(getWebDriver())
	            .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
	            .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
	            .ignoring(NoSuchElementException.class);
	 
	 visibleWait.until(ExpectedConditions.visibilityOfAllElements(Elements));
}
 

Example 21

Project: WebAutomation_AllureParallel   File: FluentWaiting.java   View source code5 votesvote downvote up
public static void waitForTitleToBe(int TotalTimeInSeconds, int PollingTimeInMilliseconds, String PageTitle)
{
	 FluentWait<WebDriver> titleWait = new FluentWait<WebDriver>(getWebDriver())
	            .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
	            .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
	            .ignoring(NoSuchElementException.class);
	 
	 titleWait.until(ExpectedConditions.titleContains(PageTitle));
}
 

Example 22

Project: qa-automation   File: WebDriverUtils.java   View source code5 votesvote downvote up
public static void waitForElementPresent(WebDriver driver, WebElement element){
    Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
            .withTimeout(60, SECONDS)
            .pollingEvery(5, SECONDS)
            .ignoring(NoSuchElementException.class);
    wait.until(ExpectedConditions.visibilityOf(element));
}
 

Example 23

Project: aet   File: WaitForHelper.java   View source code5 votesvote downvote up
/**
 * This helper method allows a Selenium WebDriver to wait until one or more ExpectedConditions are
 * met. The WebDriver waits for each ExpectedCondition to be met in a sequence, probing the page
 * every 500ms until the ExpectedCondition is met or the timeout limit is reached.
 *
 * @param webDriver The instance of a WebDriver navigating the page under test
 * @param timeoutInSeconds The time after which waiting ends unless the ExpectedCondition is met
 * earlier.
 * @param expectedConditions One or more of ExpectedConditions that have to be met.
 */
public static CollectorStepResult waitForExpectedCondition(
    WebDriver webDriver,
    long timeoutInSeconds,
    ExpectedCondition<?>... expectedConditions) {
  FluentWait<WebDriver> wait = new FluentWait<>(webDriver).withTimeout(timeoutInSeconds,
      TimeUnit.SECONDS).pollingEvery(500, TimeUnit.MILLISECONDS)
      .ignoring(NoSuchElementException.class, StaleElementReferenceException.class);

  for (ExpectedCondition<?> expectedCondition : expectedConditions) {

    wait.until(expectedCondition);
  }
  return CollectorStepResult.newModifierResult();
}
 

Example 24

Project: gridmize   File: BaseCell.java   View source code5 votesvote downvote up
public void click() {
		By bySelector = By.cssSelector(getFormatedSelector());
		new FluentWait<WebDriver>(getDriver())
				.withTimeout(5, TimeUnit.SECONDS)
				.pollingEvery(100, TimeUnit.MILLISECONDS)
				.ignoring(NoSuchElementException.class)
				.until(ExpectedConditions.elementToBeClickable(bySelector))
				.click();
		waitScreenLoader();
}
 

Example 25

Project: gridmize   File: BaseCell.java   View source code5 votesvote downvote up
private void waitElementClose(String Css, int timeout) {
	new FluentWait<WebDriver>(getDriver())
			.withTimeout(100, TimeUnit.SECONDS)
			.pollingEvery(100, TimeUnit.MILLISECONDS)
			.ignoring(NoSuchElementException.class)
			.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(Css)));
}
 

Example 26

Project: brixen   File: WaitForElementVisible.java   View source code5 votesvote downvote up
/**
 * Polls the specified {@code WebElement} at the specified polling interval until it becomes visible or the
 * polling timeout expires.
 *
 * @param element           the {@code WebElement} that is expected to become visible
 * @param pollingTimeout    the polling timeout in seconds to poll the {@code WebElement} for visibility status
 * @param pollingInterval   the polling interval in seconds between checks for the visibility status of the
 *                          {@code WebElement}
 */
public void accept(WebElement element, Integer pollingTimeout, Integer pollingInterval) {
    new FluentWait<>(element)
            .withTimeout(pollingTimeout, TimeUnit.SECONDS)
            .pollingEvery(pollingInterval, TimeUnit.SECONDS)
            .until((WebElement element1) -> {
                try {
                    return element1.isDisplayed();
                } catch(NoSuchElementException | StaleElementReferenceException e) {
                    return false;
                }
            });
}
 

Example 27

Project: brixen   File: WaitForAlertNotPresent.java   View source code5 votesvote downvote up
public void accept(final WebDriver driver, final Integer pollingTimeoutInSeconds, final Integer
        pollingIntervalInSeconds) {
    new FluentWait<>(driver)
            .withTimeout(pollingTimeoutInSeconds, TimeUnit.SECONDS)
            .pollingEvery(pollingIntervalInSeconds, TimeUnit.SECONDS)
            .until((WebDriver driver1) -> !(new IsAlertPresent().test(driver1)));
}
 

Example 28

Project: brixen   File: WaitForJQueryToComplete.java   View source code5 votesvote downvote up
public void accept(final WebDriver driver, final Integer pollingTimeoutInSeconds, final Integer
        pollingIntervalInSeconds) {
    new FluentWait<>(driver)
            .withTimeout(pollingTimeoutInSeconds, TimeUnit.SECONDS)
            .pollingEvery(pollingIntervalInSeconds, TimeUnit.SECONDS)
            .until((WebDriver driver1) -> {
        return new IsJQueryComplete().test(driver1);
    });
}
 

Example 29

Project: brixen   File: WaitForElementNotVisible.java   View source code5 votesvote downvote up
/**
 * Polls the specified {@code WebElement} at the specified polling interval until it becomes invisible or the
 * polling timeout expires.
 *
 * @param element           the {@code WebElement} that is expected to become invisible
 * @param pollingTimeout    the polling timeout in seconds to poll the {@code WebElement} for visibility status
 * @param pollingInterval   the polling interval in seconds between checks for the visibility status of the
 *                          {@code WebElement}
 */
public void accept(WebElement element, Integer pollingTimeout, Integer pollingInterval) {
    new FluentWait<>(element)
            .withTimeout(pollingTimeout, TimeUnit.SECONDS)
            .pollingEvery(pollingInterval, TimeUnit.SECONDS)
            .until((WebElement element1) -> {
                try {
                    return element1.isDisplayed();
                } catch(NoSuchElementException | StaleElementReferenceException e) {
                    return true;
                }
            });
}
 

Example 30

Project: de.lgohlke.selenium-webdriver   File: ErrorLoggingWebDriverEventListener.java   View source code5 votesvote downvote up
private boolean isExceptionFromFluentWait(Throwable throwable) {
    if (!(throwable instanceof NoSuchElementException)) {
        return false;
    }

    for (StackTraceElement stackTraceElement : throwable.getStackTrace()) {
        if (FluentWait.class.getName().equals(stackTraceElement.getClassName())) {
            return true;
        }
    }
    return false;
}
 

Example 31

Project: che   File: CodenvyEditor.java   View source code5 votesvote downvote up
private void waitJavaDocPopupSrcAttributeIsNotEmpty() {
  new FluentWait<>(seleniumWebDriver)
      .withTimeout(LOAD_PAGE_TIMEOUT_SEC * 2, SECONDS)
      .pollingEvery(LOAD_PAGE_TIMEOUT_SEC / 2, SECONDS)
      .ignoring(StaleElementReferenceException.class, NoSuchElementException.class)
      .until(ExpectedConditions.attributeToBeNotEmpty(autocompleteProposalJavaDocPopup, "src"));
}
 

Example 32

Project: che   File: CodenvyEditor.java   View source code5 votesvote downvote up
private String getElementSrcLink(WebElement element) {
  FluentWait<WebDriver> srcLinkWait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(LOAD_PAGE_TIMEOUT_SEC, SECONDS)
          .pollingEvery(500, MILLISECONDS)
          .ignoring(StaleElementReferenceException.class, NoSuchElementException.class);

  return srcLinkWait.until((ExpectedCondition<String>) driver -> element.getAttribute("src"));
}
 

Example 33

Project: che   File: OrganizationListPage.java   View source code5 votesvote downvote up
private void waitForElementDisappearance(String xpath) {
  FluentWait<SeleniumWebDriver> wait =
      new FluentWait<>(seleniumWebDriver)
          .withTimeout(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(StaleElementReferenceException.class);

  wait.until(
      (Function<WebDriver, Boolean>)
          driver -> {
            List<WebElement> elements = seleniumWebDriver.findElements(By.xpath(xpath));
            return elements.isEmpty() || !elements.get(0).isDisplayed();
          });
}
 

Example 34

Project: che   File: AddMember.java   View source code5 votesvote downvote up
private void waitForElementDisappearance(String xpath) {
  FluentWait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(StaleElementReferenceException.class);

  wait.until(
      (Function<WebDriver, Boolean>)
          driver -> {
            List<WebElement> elements = seleniumWebDriver.findElements(By.xpath(xpath));
            return elements.isEmpty() || elements.get(0).isDisplayed();
          });
}
 

Example 35

Project: che   File: AddMember.java   View source code5 votesvote downvote up
/**
 * Wait for popup is attached to DOM and animation ends.
 *
 * @param xpath xpath to match the 'che-popup' element
 */
private void waitForPopupAppearence(String xpath) {
  FluentWait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(StaleElementReferenceException.class);

  Map<String, Integer> lastSize = new HashMap<>();
  lastSize.put("height", 0);
  lastSize.put("width", 0);

  wait.until(
      (Function<WebDriver, Boolean>)
          driver -> {
            List<WebElement> elements = seleniumWebDriver.findElements(By.xpath(xpath));
            if (elements.isEmpty()) {
              return false;
            }

            Dimension size = elements.get(0).getSize();
            if (lastSize.get("height") < size.getHeight()
                || lastSize.get("width") < size.getHeight()) {
              lastSize.put("height", size.getHeight());
              lastSize.put("width", size.getWidth());

              return false;
            }

            return true;
          });
}
 

Example 36

Project: che   File: PullRequestPanel.java   View source code5 votesvote downvote up
public void openPullRequestOnGitHub() {
  Wait<WebDriver> wait =
      new FluentWait(seleniumWebDriver)
          .withTimeout(ATTACHING_ELEM_TO_DOM_SEC, SECONDS)
          .pollingEvery(500, MILLISECONDS)
          .ignoring(WebDriverException.class);
  wait.until(visibilityOfElementLocated(By.xpath(PullRequestLocators.OPEN_GITHUB_BTN))).click();
}
 

Example 37

Project: che   File: Consoles.java   View source code5 votesvote downvote up
public void openServersTabFromContextMenu(String machineName) {
  Wait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(ELEMENT_TIMEOUT_SEC, SECONDS)
          .pollingEvery(500, MILLISECONDS)
          .ignoring(WebDriverException.class);

  WebElement machine =
      wait.until(visibilityOfElementLocated(By.xpath(format(MACHINE_NAME, machineName))));
  wait.until(visibilityOf(machine)).click();

  actionsFactory.createAction(seleniumWebDriver).moveToElement(machine).contextClick().perform();
  redrawDriverWait.until(visibilityOf(serversMenuItem)).click();
}
 

Example 38

Project: che   File: CommandsToolbar.java   View source code5 votesvote downvote up
/** wait appearance of process timer on commands toolbar and try to get value of the timer */
public String getTimerValue() {
  Wait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(StaleElementReferenceException.class);

  return wait.until(driver -> driver.findElement(By.id(Locators.TIMER_LOCATOR)).getText());
}
 

Example 39

Project: che   File: Swagger.java   View source code5 votesvote downvote up
/** expand 'workspace' item */
private void expandWorkSpaceItem() {
  Wait fluentWait =
      new FluentWait(seleniumWebDriver)
          .withTimeout(LOAD_PAGE_TIMEOUT_SEC, SECONDS)
          .pollingEvery(MINIMUM_SEC, SECONDS)
          .ignoring(StaleElementReferenceException.class, NoSuchElementException.class);
  fluentWait.until((ExpectedCondition<Boolean>) input -> workSpaceLink.isEnabled());
  workSpaceLink.click();
}
 

Example 40

Project: che   File: JavaTestRunnerPluginConsole.java   View source code5 votesvote downvote up
/**
 * Wait single method in the result tree marked as failed (red color).
 *
 * @param nameOfFailedMethods name of that should fail
 */
public void waitMethodMarkedAsFailed(String nameOfFailedMethods) {
  FluentWait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(ATTACHING_ELEM_TO_DOM_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(NotFoundException.class, StaleElementReferenceException.class);
  String xpathToExpectedMethod = "//span[@id='%s']/following-sibling::*/div[text()='%s']";
  wait.until(
      ExpectedConditions.visibilityOfElementLocated(
          By.xpath(
              String.format(
                  xpathToExpectedMethod, METHODS_MARKED_AS_FAILED, nameOfFailedMethods))));
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值