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:co.edu.uniandes.csw.bookstore.selenium.EditorialIT.java

@Test
@InSequence(2)//  w w  w.j  a v a  2  s . co m
public void editFirstEditorial(@InitialPage EditorialPage editorialPage) {
    EditorialDTO editorial = factory.manufacturePojo(EditorialDTO.class);
    editorialPage.editFirstEditorial(editorial);
    WebElement name1 = browser.findElement(By.id("0-name"));
    Assert.assertTrue(name1.isDisplayed());
    Assert.assertEquals(editorial.getName(), name1.getText());
}

From source file:com.atomicleopard.webelemental.matchers.IsVisibleMatcherTest.java

License:Open Source License

@Test
public void shouldReturnTrueIfElementHasAttributeMatchingMatcher() {
    WebElement webElement1 = ElementTest.webElement("div", null,
            Expressive.<String, String>map("value", "value1"));
    WebElement webElement2 = ElementTest.webElement("div", null,
            Expressive.<String, String>map("value", "value2"));
    Element element = new Element(list(webElement1, webElement2));
    assertThat(new IsVisibleMatcher().matches(element), is(false));

    when(webElement2.isDisplayed()).thenReturn(true);
    assertThat(new IsVisibleMatcher().matches(element), is(false));

    when(webElement1.isDisplayed()).thenReturn(true);
    assertThat(new IsVisibleMatcher().matches(element), is(true));
}

From source file:com.cengage.mindtap.keywords.BasePageActions.java

protected void waitForSpinnerToDisappear() {
    int i = 0;/*from   w  ww .ja  v  a2 s  .  c o m*/
    wait.resetImplicitTimeout(5);
    try {
        List<WebElement> spinnerGifs = driver
                .findElements(By.xpath("//img[contains(@src, '/nb/ui/images/savingAnimation_')]"));
        if (spinnerGifs.size() > 0) {
            for (WebElement spinnerGif : spinnerGifs) {
                while (spinnerGif.isDisplayed() && i <= AJAX_WAIT) {
                    wait.hardWait(5);
                    i++;
                }
            }
        }
    } catch (Exception e) {
    }
    wait.resetImplicitTimeout(AJAX_WAIT);
}

From source file:com.cengage.mindtap.keywords.EvernotePageActions.java

public void editNote() throws AWTException {
    waitTOSync();//from w  ww  .  j  a  va2s.co m
    waitTOSync();
    element("editNote").click();
    element("Note_Title").clear();
    element("Note_Title").sendKeys("Instructor edited Note");
    switchToDefaultContent();
    switchToDockIFrame();
    switchToFrame("tinymce_editor_area_ifr");

    waitTOSync();
    WebElement element = driver.findElement(By.id("tinymce"));
    driver.findElement(By.id("tinymce")).clear();
    System.out.println("Editing note description in text input");
    //element.sendKeys(Keys.CONTROL + "a");
    element.sendKeys(Keys.CONTROL + "b");

    element.sendKeys("bold edited");

    element.sendKeys(Keys.CONTROL + "b");
    element.sendKeys(Keys.ENTER);
    element.sendKeys(Keys.CONTROL + "i");
    element.sendKeys("Italics edited");

    element.sendKeys(Keys.ENTER);
    element.sendKeys(Keys.CONTROL + "i");
    element.sendKeys("hyperlinked");
    element.sendKeys(Keys.chord(Keys.SHIFT, Keys.HOME));
    waitTOSync();
    switchToDefaultContent();
    switchToDockIFrame();
    element("hyperlink").click();

    windowHandle = driver.getWindowHandle();
    ArrayList<String> tabs2 = new ArrayList<String>(driver.getWindowHandles());
    driver.switchTo().window(tabs2.get(1));
    element("linkBox").clear();
    element("linkBox").sendKeys("http://google.com");
    element("LinkInsert").click();
    waitTOSync();
    driver.switchTo().window(windowHandle);
    System.out.println("window switched");
    switchToDefaultContent();
    switchToDockIFrame();
    switchToFrame("tinymce_editor_area_ifr");
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    Assert.assertTrue(element("linkedText").isDisplayed(), "text is not linked");

    switchToDefaultContent();
    switchToDockIFrame();
    element("updateNode_Button").click();
    waitTOSync();
    String addedNote_Title = driver.findElement(By.xpath(".//ul[@class='plain']/li[1]/a")).getText();
    System.out.println(addedNote_Title);
    Assert.assertTrue(addedNote_Title.contains("edited Note"), "edited note is not displayed");

    WebElement bold = driver.findElement(By.xpath("//strong[contains(text(),'bold edited')]"));
    Assert.assertTrue(bold.isDisplayed(), "bold text does not appear");

    WebElement italics = driver.findElement(By.xpath("//em[contains(text(),'Italics edited')]"));
    Assert.assertTrue(italics.isDisplayed(), "italics text does not appear");

    ReportMsg.info("Instructor successfuly edited note");
}

From source file:com.cengage.mindtap.keywords.GradeBookAppPageAction.java

public void verifyTotalPossiblePointsInGrid() {
    for (WebElement possiblePoints : elements("totalPossiblePoints")) {
        possiblePoints.isDisplayed();
    }//from w  ww .ja  v  a 2s.com
}

From source file:com.cengage.mindtap.keywords.GradeBookAppPageAction.java

public void verifyGradedActivitiesUnderCorrespondingUnits() {
    waitForElementPresent("gradedActivitiesTitlesInGrid");
    for (WebElement gradedActivityTitle : elements("gradedActivitiesTitlesInGrid")) {
        gradedActivityTitle.isDisplayed();
    }//from w w  w.ja  v  a 2 s  .  co  m
}

From source file:com.cengage.mindtap.keywords.MasterPageActions.java

public void clickBookModifyOption(String searchTerm, String option, String role) {
    int optionNumber = 0;
    int optionsCount = 0;
    int i = 0;//  w w w.ja  v a 2  s.c  o  m
    optionNumber = findoptionNumber(option, role);

    List<WebElement> masterBook_list = driver
            .findElements(By.xpath("//li[contains(@class, 'item  master admin_models_master')]"));
    for (WebElement masterBook : masterBook_list) {
        System.out.println("In masterBook ");
        //if (masterBook.findElement(By.xpath("(//div/div[@class='listText']/a)[2]")).getText().equals(searchTerm)  || masterBook.findElement(By.xpath("//div/div[@class='listText']/a")).getText().equals(searchTerm)) {
        if (masterBook.findElement(By.xpath("//div/div[@class='listText']/a")).getText().equals(searchTerm)) {
            System.out.println("In IF ");
            String bookClassName = masterBook.getAttribute("class");
            System.out.println("optionCount : " + optionNumber);
            executeJavascript("document.getElementsByClassName('" + bookClassName
                    + "')[0].getElementsByTagName('a')[" + optionNumber + "].style.display = 'block';");
            wait.hardWait(2);
            for (WebElement option1 : elements("masterBookControlOptions_list", option)) {
                try {
                    System.out.println("optionCount : " + optionNumber);
                    System.out.println(option1.getAttribute("alt"));
                    System.out.println(option);
                    if (option1.isDisplayed() && option1.getAttribute("alt").equals(option)) {
                        System.out.println("optionCount : " + optionNumber);
                        executeJavascript("document.getElementsByClassName('" + bookClassName
                                + "')[0].getElementsByTagName('a')[" + optionNumber
                                + "].style.display = 'block';");
                        hover(option1);
                        clickOnElementUsingActionBuilder(option1);

                        if (option.equals("Delete")) {
                            handleAlert();
                            wait.hardWait(20);
                        }
                        break;
                    }
                } catch (ElementNotFoundException e) {
                    System.out.println("Options are not available to Click");
                }
            }
            break;
        }
    }
}

From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java

License:Open Source License

/**
 * Selects an option from dropdown./*from  w w  w .j av a 2s  .  c  o m*/
 * 
 * @param dropDown
 *            the drop down
 * @param optionsListXpath
 *            the options list xpath
 * @param option
 *            the option
 */
public static void selectFromDropdown(WebElement dropDown, String optionsListXpath, String option) {
    waitForElement(dropDown);
    if (dropDown.isDisplayed() && dropDown.isEnabled()) {
        click(dropDown);

        String initialValue = driver.switchTo().activeElement().getText();
        boolean found = false;

        while (found == false) {
            driver.switchTo().activeElement().sendKeys(Keys.ARROW_DOWN);
            if (driver.switchTo().activeElement().getText().equals(initialValue)) {
                break;
            } else {
                if (driver.switchTo().activeElement().getText().equals(option)) {
                    LogHandler.printToConsole(
                            "\tSelecting the option : " + driver.switchTo().activeElement().getText());
                    driver.switchTo().activeElement().click();
                    found = true;
                }

            }
        }
    }

}

From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java

License:Open Source License

/**
 * Verifies if element is displayed.//from   www.j a  va  2  s . co  m
 * 
 * @param element
 *            - WebElement
 * @return - true if displayed, false otherwise
 */
public static boolean isElementDisplayed(WebElement element) {
    return element.isDisplayed();
}

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Gets the visible elements./*w  w  w.j a  v  a 2  s . c  om*/
 * Returns an array of webElements that are visible.
 * If there are no visible DOM elements that match the criteria, then NULL is returned.
 *
 * @param driver the driver
 * @param locator the locator
 * @param timeout the timeout
 * @return the visible elements
 */
public static List<WebElement> getVisibleElements(final WebDriver driver, final By locator,
        final Timeout timeout) {

    final List<WebElement> visibleElements = new ArrayList<>();
    try {
        for (final WebElement element : getElements(driver, locator, timeout)) {
            if (element.isDisplayed()) {
                visibleElements.add(element);
            }
        }
    } catch (Exception ex) {
        LogUtil.log("Element either not found or not visible.", LogLevel.HIGH);
    }
    return visibleElements;
}