Example usage for org.openqa.selenium.support.ui FluentWait until

List of usage examples for org.openqa.selenium.support.ui FluentWait until

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui FluentWait until.

Prototype

@Override
public <V> V until(Function<? super T, V> isTrue) 

Source Link

Document

Repeatedly applies this instance's input value to the given function until one of the following occurs:
  1. the function returns neither null nor false
  2. the function throws an unignored exception
  3. the timeout expires
  4. the current thread is interrupted

Usage

From source file:ru.tanyasun.delightex.ft.CreateChatTest.java

License:Open Source License

@Test
public void testCreateChat() {
    String userName = TestUtils.makeUserName();
    TestUtils.verifyLoginBox(browser);//from  w w  w. j a  v  a2s.  c o m
    TestUtils.doLogin(browser, userName);
    WebElement chatNameEdit = browser.findElement(By.xpath("//input[@type='text']"));
    String newChatName = TestUtils.makeChatName();
    chatNameEdit.sendKeys(newChatName);

    WebElement createButton = browser.findElement(By.xpath("//button[@type='button']"));
    createButton.click();

    browser.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

    //By chatNameCondition = By.xpath("//a[contains(text(), '"+newChatName+"')]");
    //WebElement chatLink = browser.findElement(chatNameCondition);
    //chatLink.click();

    WebElement captionDiv = browser.findElement(By.xpath(TestUtils.CAPTION_DIV_PATH));
    String captionText = captionDiv.getText();

    assertTrue(captionText.contains(userName));
    assertTrue(captionText.contains("you are in"));
    assertTrue(captionText.contains(newChatName));
    assertTrue(captionText.contains("chat room"));

    WebElement chatTable = browser.findElement(By.xpath(TestUtils.CHAT_TABLE_XPATH));

    By greetingCondition = By.xpath("//div[contains(text(), 'Hello! You are in a chat!')]");

    FluentWait<By> messageWait = new FluentWait<By>(greetingCondition);
    messageWait.pollingEvery(100, TimeUnit.MILLISECONDS);
    messageWait.withTimeout(1000, TimeUnit.MILLISECONDS);
    messageWait.until(new Predicate<By>() {
        public boolean apply(By by) {
            try {
                return browser.findElement(by).isDisplayed();
            } catch (NoSuchElementException ex) {
                return false;
            }
        }
    });
    WebElement adminGreeting = browser.findElement(greetingCondition);
    String greetingText = adminGreeting.getText();
    assertEquals("Hello! You are in a chat!", greetingText);

}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.BioEntitiesPage.java

License:Apache License

public List<BaselineBioEntitiesSearchResult> getBaselineResults(boolean hasSpecies, boolean onlyVisible) {
    List<BaselineBioEntitiesSearchResult> baselineCounts = Lists.newArrayList();

    By byBaselineCountsTableId = By.id("baselineCountsTable");
    FluentWait wait = new WebDriverWait(driver, 25L).pollingEvery(20, TimeUnit.MILLISECONDS);
    wait.until(ExpectedConditions.visibilityOfElementLocated(byBaselineCountsTableId));

    List<WebElement> linkElements = driver
            .findElements(By.cssSelector("#baselineCountsTable .bioEntityCardLink"));

    for (WebElement linkElement : linkElements) {
        if (onlyVisible && !linkElement.isDisplayed()) {
            continue;
        }//  ww w  .  jav a 2s . c om
        baselineCounts.add(buildBaselineEntityCount(linkElement, null, hasSpecies));
    }

    return baselineCounts;
}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.HeatmapTablePage.java

License:Apache License

public String getDifferentialExperimentTooltipTableHeader(int zeroBasedProfileIndex,
        int zeroBasedExpressionLevelIndex, int zeroBasedTooltipTableHeaderIndex,
        ExperimentType experimentType) {
    WebElement firstGeneProfileCell = getGeneProfileCell(zeroBasedProfileIndex, zeroBasedExpressionLevelIndex);
    hoverOnElement(firstGeneProfileCell);

    By byTooltipClass = By/*from   ww w.  java 2  s.  com*/
            .xpath("//div[@class='ui-tooltip-content']//th[" + (zeroBasedTooltipTableHeaderIndex + 1) + "]");
    FluentWait wait = new WebDriverWait(driver, 4L).pollingEvery(1, TimeUnit.SECONDS);
    wait.until(ExpectedConditions.visibilityOfElementLocated(byTooltipClass));
    return driver.findElement(byTooltipClass).getText();
}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.HeatmapTablePage.java

License:Apache License

public String getDifferentialExperimentTooltipTableCell(int zeroBasedProfileIndex,
        int zeroBasedExpressionLevelIndex, int zeroBasedTooltipTableCellIndex, ExperimentType experimentType) {
    hoverOnElement(getGeneProfileCell(0, zeroBasedExpressionLevelIndex));

    By byTooltipClass = By//from  w w  w .  j  a  va2 s  .  c om
            .xpath("//div[@class='ui-tooltip-content']//td[" + (zeroBasedTooltipTableCellIndex + 1) + "]");
    FluentWait wait = new WebDriverWait(driver, 4L).pollingEvery(1, TimeUnit.SECONDS);
    wait.until(ExpectedConditions.visibilityOfElementLocated(byTooltipClass));
    return driver.findElement(byTooltipClass).getText();
}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.HeatmapTablePage.java

License:Apache License

public String getFactorTooltipContent(int oneBasedHeaderColumn, int zeroBasedTooltipTableRowIndex,
        int zeroBasedTooltipTableColumnIndex) {
    hoverOnHeaderColumn(oneBasedHeaderColumn);

    By byTooltipClass = By.xpath("//div[@class='ui-tooltip-content']//tr[" + (zeroBasedTooltipTableRowIndex + 1)
            + "]//td[" + (zeroBasedTooltipTableColumnIndex + 1) + "]");
    FluentWait wait = new WebDriverWait(driver, 6L).pollingEvery(50, TimeUnit.MILLISECONDS);
    wait.until(ExpectedConditions.visibilityOfElementLocated(byTooltipClass));
    return driver.findElement(byTooltipClass).getText();

}

From source file:uk.ac.ebi.atlas.bioentity.widget.GenePageControllerBaselineWidgetGallusGallusSIT.java

License:Apache License

@Test
public void baselinePaneHasResults() {
    String widgetBody = subject.getBaselinePaneHeaderResultsMessage();
    assertThat(widgetBody, is("Results in tissues"));

    FluentWait wait = new WebDriverWait(driver, 10L).pollingEvery(1, TimeUnit.SECONDS);
    wait.until(ExpectedConditions.textToBePresentInElement(By.cssSelector(".bioEntityCardDifferentialSummary"),
            "Within Sample Abundance (Proteomics) > 0"));

    assertThat(subject.isBaselinePaneExpanded(), is(true));

    assertThat(subject.getGeneNames().size(), is(1));
    assertThat(subject.getGeneNames(), contains("Vertebrate tissues"));

}

From source file:utils.WebDriverUtils.java

public static void waitForFileDownload(String prepaidcardCvsPath) {
    FluentWait<File> waiter = new FluentWait<File>(new File(prepaidcardCvsPath));
    waiter.withTimeout(30, TimeUnit.SECONDS);
    waiter.pollingEvery(1000, TimeUnit.MILLISECONDS);
    waiter.until(new Predicate<File>() {
        @Override/*from w  w  w . j a  va  2  s .  c  om*/
        public boolean apply(File input) {
            return input.exists() && input.length() > 0;
        }
    });
}