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:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Select option by value./*  w w  w.  j av  a  2 s .co m*/
 * @param driver the driver
 * @param cssSelector the css selector
 * @param selectValue the select value
 */
public static void selectOptionValueByCSS(final WebDriver driver, final String cssSelector,
        final String selectValue) {

    logger.info("Select css selector:" + cssSelector + " ; selectValue" + selectValue);
    List<WebElement> elements = driver.findElements(By.cssSelector(cssSelector));
    for (WebElement element : elements) {
        if (element.isDisplayed() && element.isEnabled()) {
            Select select = new Select(element);
            select.selectByValue(selectValue);
        }
    }
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Checks if is element exists by id./*  w w w  . j  a v a  2 s  .  co m*/
 * @param driver the driver
 * @param element the element
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return true, if is element exists by id
 */
public static boolean isElementExistsById(final WebDriver driver, final WebElement element,
        final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    try {
        isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {

                WebElement element1 = element.findElement(By.id(fieldname));
                return element1.isDisplayed();
            }
        });
    } catch (TimeoutException te) {
        isLoaded = false;
    }
    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Check according to the link text./*from   ww w . j a va 2 s .c  om*/
 * @param driver the driver
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isDisplayedByLinkText(final WebDriver driver, final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            WebElement element = driver.findElement(By.linkText(fieldname));
            return element.isDisplayed();
        }
    });
    return isLoaded;
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.BaseSelector.java

License:Open Source License

protected boolean isDisplayedAction(String name) {
    WebElement element = getWebElement(name);
    return element != null && element.isDisplayed();
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.Dropdown.java

License:Open Source License

@Override
protected boolean isDisplayedAction(String name) {
    WebElement element;
    try {//from   w  w w .  j av  a 2  s. c  om
        element = elementByName != null ? elementByName.get(Selector.class).getWebElement(name)
                : getWebElement(name);
    } catch (Exception | Error ex) {
        return false;
    }
    return element != null && element.isDisplayed();
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.TextList.java

License:Open Source License

public boolean waitVanishedAction() {
    return avatar.findImmediately(() -> timer().wait(() -> {
        List<WebElement> elements = getWebElements();
        if (elements == null || elements.size() == 0)
            return true;
        for (WebElement el : getWebElements())
            if (el.isDisplayed())
                return false;
        return true;
    }), false);//from w ww.  j  a v a 2 s . co  m
}

From source file:com.epam.jdi.uitests.web.selenium.elements.complex.Dropdown.java

License:Open Source License

@Override
protected boolean isDisplayedAction(String name) {
    WebElement element;
    try {/*from   w  ww .  j av  a  2  s  .  com*/
        element = allLabels.get(TextList.class).getElement(name);
    } catch (Exception | Error ex) {
        return false;
    }
    return element != null && element.isDisplayed();
}

From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java

License:Apache License

/**
 * Edits Field.//from w w  w . j av  a 2s  . c  o  m
 *
 * @param fieldid {@link String}
 * @param values {@link Map}
 * @throws InterruptedException InterruptedException
 */
private void editField(final String fieldid, final Map<String, String> values) throws InterruptedException {

    clickEditFieldButton(fieldid);

    getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform")));

    for (Map.Entry<String, String> e : values.entrySet()) {
        String field = e.getKey();
        String value = e.getValue();

        By by = By.xpath("//*[self::textarea|self::input|self::select|self::button]" + "[@data-fieldid='"
                + field + "']");

        WebElement element = findElementBy(by);

        assertTrue(element.isDisplayed());
        String tagname = element.getTagName();

        switch (tagname) {
        case "select":
            Select select = new Select(element);
            waitUntilSelectOptionsPopulated(select);
            select.selectByVisibleText(extractLabelAndValue(value).getLeft());
            break;

        case "button":
            element.click();
            break;
        default:
            element.clear();
            element.sendKeys(value);
            break;
        }
    }

    //findElementBy(By.className("form-modal-update-button")).click();
    click(By.name("_eventId_next"));

    getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("fieldeditorform")));
}

From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java

License:Apache License

/**
 * testAddWorkflow07()./*  w w w  .ja  va2 s  . c  o  m*/
 * add Password and then edit..
 *
 * @throws Exception Exception
 */
@Test
public void testAddWorkflow07() throws Exception {
    // given
    FormJSONFieldType typeSelect = FormJSONFieldType.PASSWORD;
    ImmutableMap<String, String> values = ImmutableMap.of("20", "new field", "40", "Immediate[immediate]");

    // when - add step
    clickAddNewWorkflow();
    addBlankForm();

    menuDragAndDrop("menu-password");

    // then
    WebElement element = findElementBy("input", "data-fieldid", "1");
    assertTrue(element.isDisplayed());
    assertEquals("password", element.getAttribute("type"));

    checkEditField("1", typeSelect, values);
}

From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java

License:Apache License

/**
 * testAddWorkflow10().//from   w  w  w  . j  a  va2 s .  c  o  m
 * add Signature Initials and then edit..
 *
 * @throws Exception Exception
 */
@Test
public void testAddWorkflow10() throws Exception {
    // given
    FormJSONFieldType typeSelect = FormJSONFieldType.SIGNATURE_INITIALS;
    ImmutableMap<String, String> values = ImmutableMap.of("20", "new field", "40", "Immediate[immediate]");

    // when - add step
    clickAddNewWorkflow();
    addBlankForm();

    menuDragAndDrop("menu-initials");

    // then
    WebElement element = findElementBy("input", "data-fieldid", "1");
    assertTrue(element.isDisplayed());
    assertEquals("XX", element.getAttribute("placeholder"));

    checkEditField("1", typeSelect, values);
}