Example usage for org.openqa.selenium WebElement isDisplayed

List of usage examples for org.openqa.selenium WebElement isDisplayed

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement isDisplayed.

Prototype

boolean isDisplayed();

Source Link

Document

Is this element displayed or not?

Usage

From source file:edu.umd.cs.guitar.ripper.WebRipperMonitor.java

License:Open Source License

@Override
public boolean isExpandable(GComponent component, GWindow window) {
    if (!(component instanceof WebComponent))
        return false;

    WebComponent webCompnent = (WebComponent) component;
    WebElement webElement = webCompnent.getElement();
    if (webElement == null)
        return false;

    if ((!webElement.isDisplayed()) || (!webElement.isEnabled())) {
        GUITARLog.log.debug("Ignore expanding because the element is either not displayed nor enabled ");
        return false;
    }// w ww.j  a v  a 2 s. c o m

    return true;
}

From source file:eu.jasha.portaltests.steps.NewUserSteps.java

License:Apache License

@Then("I see my portal page with the add new widgets box")
public void iSeeMyEmptyPortalPage() {
    final WebElement emptyPageBox = portal.getEmptyPageBox();
    assertThat(emptyPageBox.isDisplayed(), equalTo(Boolean.TRUE));
}

From source file:gov.nih.nci.firebird.commons.selenium2.util.WebElementUtils.java

License:Open Source License

/**
 * Checks an element on the page to indicate if the object is visible on the page or not.
 *
 * @param element The WebElement object to check
 * @return if the element does not present itself with a "display : none" style.
 *///from w w  w. j a v a2 s.c  o m
public static boolean isVisible(WebElement element) {
    try {
        return element.isDisplayed();
    } catch (NoSuchElementException e) {
        return false;
    } catch (StaleElementReferenceException e) {
        return false;
    }
}

From source file:gov.nih.nci.firebird.selenium2.pages.components.tags.CommentsTag.java

License:Open Source License

private static WebElement getCommentsDiv(final WebDriver driver) {
    List<WebElement> commentsDivs = driver.findElements(By.id(COMMENTS_DIV_ID));
    return Iterables.find(commentsDivs, new Predicate<WebElement>() {
        @Override/*w  w  w .j a v  a 2s  .co m*/
        public boolean apply(WebElement div) {
            return div.isDisplayed();
        }
    }, null);
}

From source file:gov.nih.nci.firebird.selenium2.pages.components.tags.SponsorReviewRegistrationFormsTable.java

License:Open Source License

private WebElement getTable() {
    return Iterables.find(findElements(By.id(TABLE_ID)), new Predicate<WebElement>() {
        public boolean apply(WebElement table) {
            return table.isDisplayed();
        }/*  w  w  w  .j a  v  a  2s  .  c o  m*/
    });
}

From source file:gov.nih.nci.firebird.selenium2.pages.investigator.profile.EditTrainingCertificateDialog.java

License:Open Source License

private WebElement getSearchAgainButtonIfPresent() {
    for (WebElement searchAgainButton : findElements(By.id(SEARCH_AGAIN_BUTTON_ID))) {
        if (searchAgainButton.isDisplayed()) {
            return searchAgainButton;
        }/*from   ww w . j av  a2 s. c  o  m*/
    }
    return null;
}

From source file:gov.nih.nci.firebird.selenium2.pages.sponsor.protocol.review.ReviewRegistrationTab.java

License:Open Source License

private WebElement getCompleteReviewButton() {
    return Iterables.find(getDriver().findElements(By.id(COMPLETE_REVIEW_BUTTON_ID)),
            new Predicate<WebElement>() {
                @Override//www .ja  v  a  2s  .com
                public boolean apply(WebElement button) {
                    return button.isDisplayed();
                }
            });
}

From source file:influent.selenium.tests.EntityDetailsTest.java

License:MIT License

@Test
public void accountsViewButtonTest() {

    getFlowViewResults("joe");

    //Test a card that has no transactions

    List<WebElement> elements = driver.findElements(By.className("baseballcardContainer"));

    WebElement card1 = null;//from w w w  .j a  v  a  2  s  . c  o m
    for (WebElement webElement : elements) {
        if (webElement.isDisplayed()) {
            if (card1 == null) {
                card1 = webElement;
                break;
            }
        }
    }

    if (card1 == null) {
        throw new AssertionError("Couldn't find: baseballcardContainer element");
    }

    card1.click();

    //Wait a few seconds for page to load. This is needed despite waiting for presence of element
    try {
        Thread.sleep(2000);
    } catch (Exception e) {
    }

    WebElement element = (new WebDriverWait(driver, 120))
            .until(ExpectedConditions.presenceOfElementLocated(By.id("transactions-table-pagination-label")));

    element = driver.findElement(By.id("accountsViewButton"));

    element.click();

    element = (new WebDriverWait(driver, 120))
            .until(ExpectedConditions.presenceOfElementLocated(By.className("infSearchResultCounts")));
    assertEquals("Showing 1 of 1 results", element.getText());

    element = driver.findElement((By.className("simpleSearchResultText")));

    assertEquals(
            "Name:JoeDescription:Joe, 40 years old, is still single. He has been managing a livestock business, particularly hog-raising, for almost 10 years. His net income every three months is 6,000 Philippine pesos (PHP) for every hog that he sell. He's asking for a loan of 12,000 PHP to purchase livestock feeds for his hogs. He hopes that Kiva lenders ...",
            element.getText());
}

From source file:influent.selenium.tests.EntityDetailsTest.java

License:MIT License

@Test
public void entityDetailsTest() {
    getFlowViewResults("name:\"joe\" countryCode:\"PE\" datatype:loan matchtype:\"any\"");

    List<WebElement> elements = driver.findElements(By.className("baseballcardContainer"));

    WebElement card1 = null;//from   w  w w .  j  ava  2s .c om
    for (WebElement webElement : elements) {
        if (webElement.isDisplayed()) {
            if (card1 == null) {
                card1 = webElement;
                break;
            }
        }
    }

    if (card1 == null) {
        throw new AssertionError("Couldn't find: baseballcardContainer element");
    }

    card1.click();

    //Wait a few seconds for page to load. This is needed despite waiting for presence of element
    try {
        Thread.sleep(2000);
    } catch (Exception e) {
    }

    WebElement element = (new WebDriverWait(driver, 120))
            .until(ExpectedConditions.presenceOfElementLocated(By.id("details")));

    element = driver.findElement(By.className("detailsTitle"));
    assertEquals("Account Details", element.getText());

    element = driver.findElement(By.className("detailsEntityLabel"));
    assertEquals("Joe. Peru, PUCALLPA", element.getText());

    elements = driver.findElements(By.className("detailsIcon"));
    element = SeleniumUtils.getDisplayedElement(elements);
    String src = element.getAttribute("src");
    assertEquals("http://localhost:8080/kiva/rest/icon/aperture-hscb/Person?iconWidth=32&iconHeight=32", src);

    element = driver.findElement(By.id("entityDetailsImageLink"));
    String href = element.getAttribute("href");
    assertEquals("http://www.kiva.org/img/w400/1118387.jpg", href);

    elements = driver.findElements(By.tagName("tr"));
    WebElement row1 = null;
    WebElement row2 = null;
    for (WebElement webElement : elements) {
        if (webElement.isDisplayed()) {
            if (row1 == null) {
                row1 = webElement;
            } else {
                row2 = webElement;
                break;
            }
        }
    }
    assertEquals("uid: a.loan.b438363", row1.getText());
    assertEquals("Posted Date: Jun 1, 2012", row2.getText());
}

From source file:influent.selenium.tests.EntityDetailsTest.java

License:MIT License

@Test
public void clusterSummaryDetailsTest() {
    getFlowViewResults("visionfund");

    //Test a card that has no transactions
    List<WebElement> elements = driver.findElements(By.className("baseballcardContainer"));
    WebElement element = SeleniumUtils.getDisplayedElement(elements);

    element.click();/*from  w  ww.j av a2  s.  c  o  m*/

    //Wait a few seconds for page to load. This is needed despite waiting for presence of element
    try {
        Thread.sleep(2000);
    } catch (Exception e) {
    }

    element = (new WebDriverWait(driver, 120))
            .until(ExpectedConditions.presenceOfElementLocated(By.id("details")));

    element = driver.findElement(By.className("detailsTitle"));
    assertEquals("Account Details", element.getText());

    element = driver.findElement(By.className("detailsEntityLabel"));
    assertEquals("VisionFund Albania", element.getText());

    elements = driver.findElements(By.className("detailsIcon"));
    element = SeleniumUtils.getDisplayedElement(elements);
    String src = element.getAttribute("src");
    assertEquals(
            "http://localhost:8080/kiva/rest/icon/aperture-hscb/Organization?iconWidth=32&iconHeight=32&role=business",
            src);

    element = driver.findElement(By.id("entityDetailsImageLink"));
    String href = element.getAttribute("href");
    assertEquals("http://www.kiva.org/img/w400/1092590.jpg", href);

    elements = driver.findElements(By.tagName("tr"));
    WebElement row1 = null;
    WebElement row2 = null;
    for (WebElement webElement : elements) {
        if (webElement.isDisplayed()) {
            if (row1 == null) {
                row1 = webElement;
            } else {
                row2 = webElement;
                break;
            }
        }
    }
    assertEquals("uid: o.partner.p239", row1.getText());
    assertEquals("partners_cc: AL", row2.getText());
}