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.vaadin.testbench.elements.ButtonElement.java

License:Apache License

private boolean tryClickChild(WebElement e) {
    List<WebElement> children = e.findElements(By.xpath(".//*"));
    for (WebElement c : children) {
        if (c.isDisplayed()) {
            c.click();//from   www.j  a v a2  s  .  c  o  m
            return true;
        } else {
            if (tryClickChild(c)) {
                return true;
            }
        }
    }
    return false;
}

From source file:com.volkhart.selenium.util.Window.java

License:Apache License

/**
 * Provides a way of doing dynamic waits
 * /*ww  w.  ja v a2  s. c o  m*/
 * @param webElement
 *            The WebElement being waited on
 * @return Is not used but required by API
 */
public static ExpectedCondition<WebElement> isVisible(final WebElement webElement) {
    return new ExpectedCondition<WebElement>() {

        @Override
        public WebElement apply(WebDriver arg0) {
            if (webElement.isDisplayed())
                return webElement;
            return null;
        }
    };
}

From source file:com.volkhart.selenium.util.Window.java

License:Apache License

/**
 * Provides a way of doing dynamic waits
 * //  ww  w .  j av  a  2 s.co  m
 * @param locator
 *            the method by which the WebElement is identified
 * @return The WebElement once found
 */
public static ExpectedCondition<WebElement> isVisible(final By locator) {
    return new ExpectedCondition<WebElement>() {
        public WebElement apply(WebDriver sDriver) {
            WebElement toReturn = sDriver.findElement(locator);
            if (toReturn.isDisplayed()) {
                return toReturn;
            }
            return null;
        }
    };
}

From source file:com.worldline.easycukes.selenium.utils.SeleniumHelper.java

License:Open Source License

/**
 * @return//from w w  w .j  av  a  2 s.  c  om
 */
public static void waitUntilElementIsHidden(@NonNull final WebDriver driver, @NonNull final By by) {
    // Waiting for an element to be present on the page, checking for its
    // presence once every second.
    final FluentWait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS).ignoring(TimeoutException.class);

    wait.until(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver webDriver) {
            try {
                log.debug("waiting for hidden " + by);
                final List<WebElement> list = webDriver.findElements(by);
                for (final WebElement webElement : list)
                    if (webElement.isDisplayed()) {
                        log.debug("Still displayed !");// TODO
                        return false;
                    }
                return true;
            } catch (final StaleElementReferenceException e) {
                return true;
            } catch (final NoSuchElementException e) {
                return true;
            }
        }
    });
}

From source file:contentspeed.CosCumparaturi.java

boolean ExistsErrorEmail() {
    boolean result = false;
    try {/*w w  w.j  a  v  a2s .co m*/

        WebElement divExistsEmail = driver.findElement(errorDuplicateEmail);
        System.out.println(divExistsEmail.getText());
        result = divExistsEmail.isDisplayed();

    } catch (Exception ex) {

        ex.getMessage();
        return false;

    }
    return result;
}

From source file:contentspeed.ProdusCeai.java

public void clickAdaugaCos() {

    WebElement elementtobeClicked = driver.findElement(produsArmonia);

    Assert.assertTrue(elementtobeClicked.isDisplayed());

    JavascriptExecutor jsDriver = (JavascriptExecutor) driver;
    jsDriver.executeScript("arguments[0].scrollIntoView(false);", elementtobeClicked);

    jsDriver.executeScript("arguments[0].click();", elementtobeClicked);

}

From source file:customerportal.Test_HomeUse.java

@Test
public void Test_HomeUse() throws Exception {
    loginAsMyAutodeskPortalUser(testProperties.getConstant("USER_NAME"),
            testProperties.getConstant("PASSWORD"));
    CustomerPortal customerPortal = utilCreateMyAutodeskPortal();
    loginPage = customerPortal.getLoginPage();
    homePage = customerPortal.getHomePage();
    mainWindow.select();//from   ww w . jav  a 2 s . c o  m
    Util.sleep(2000);
    List<WebElement> HomeUseList = homePage.getMultipleWebElementsfromField("HomeUseList");

    for (WebElement EachHomeUser : HomeUseList) {
        if (EachHomeUser.isDisplayed()) {
            assertTrue("Home Use link exists for the product / service ", EachHomeUser.isDisplayed());
        } else {
            EISTestBase.fail("HomeUse Link doesnot exists for the product/serivce ");
        }
        Util.printInfo("clicking on Home Use button ");
        EachHomeUser.click();
        Util.sleep(4000);
        homePage.verifyFieldExists("HomeUseWindow");
        Util.sleep(4000);
        homePage.verifyFieldExists("GetLicensedForHomeUse");
        Util.sleep(4000);
        homePage.verifyFieldExists("UseThisFormForHomeUseOfNetworkLicensesOnAMaintenanceSubscription");
        Util.sleep(4000);
        homePage.verifyFieldExists("SpecifyTheProduct");
        Util.sleep(4000);
        homePage.verifyFieldExists("ViewEligibleAutodeskProductsPDF");
        Util.sleep(4000);
        homePage.verifyFieldExists("ProductNameTextBox");
        Util.sleep(4000);
        homePage.verifyFieldExists("HomeUseVersion");
        Util.sleep(4000);
        homePage.verifyFieldExists("VersionTextBox");
        Util.sleep(4000);
        homePage.verifyFieldExists("HomeUseQuantity");
        Util.sleep(4000);
        homePage.verifyFieldExists("QuantityTextBox");
        Util.sleep(4000);
        homePage.verifyFieldExists("HomeUseSubs");
        Util.sleep(4000);
        homePage.verifyFieldExists("SubscriptionTextBox");
        Util.sleep(4000);
        homePage.verifyFieldExists("HowShouldWeContactYou");
        Util.sleep(4000);
        homePage.verifyFieldExists("YourRequestMayTakeFivedays");
        Util.sleep(4000);
        homePage.verifyFieldExists("EmailRequired");
        Util.sleep(4000);
        homePage.verifyFieldExists("EmailRequiredTextBox");
        Util.sleep(4000);
        homePage.verifyFieldExists("PhoneNumberTextBox");
        Util.sleep(4000);
        homePage.verifyFieldExists("PhoneNumber");
        Util.sleep(4000);
        homePage.verifyFieldExists("SendRequest");
        Util.sleep(4000);
        homePage.verifyFieldExists("HomeUseCancel");
        Util.sleep(4000);
        Util.printInfo("Closing Home Use Window by clicking on cancel button ");
        //homePage.click("HomeUseCancel");
        driver.findElement(By.xpath(".//*[@id='home-use-modal']/footer//div/button[contains(text(),'Cancel')]"))
                .click();
        Util.sleep(4000);
        if (!(homePage.isFieldVisible("HomeUseWindow"))) {
            Util.printInfo("Home Use Window closed successfully after clicking on cancel button");
        } else {
            EISTestBase.fail("Home use Window didnot closed even after clicking on cancel button ");
        }
        EachHomeUser.click();
        Util.sleep(4000);
        homePage.verifyFieldExists("CloseIcon");
        /*Util.sleep(4000);
        Util.printInfo("Closing Home Use Window by clicking on close Icon ");*/
        //homePage.click("CloseIcon");
        //driver.findElement(By.xpath(".//*[@id='home-use-modal']/header/button[contains(@class,'close')]")).click();
        Util.sleep(4000);
        /*if(!(homePage.isFieldVisible("HomeUseWindow"))){
           Util.printInfo("Home Use Window closed successfully after clicking on close Icon ");
        }else{
           EISTestBase.fail("Home use Window didnot closed even after clicking on Close Icon on top corner side of House Use window  ");
        }*/
        break;
    }

    logoutMyAutodeskPortal();
}

From source file:dagaz.controllers.SingleThread.java

private ArrayList<String> getAvailableArenas() {
    ArrayList<String> arenas = new ArrayList<String>();
    WebDriverWait wait = new WebDriverWait(driver, 20);
    try {//from w ww. j  av  a  2  s .c  o  m
        WebElement btnArena = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath(
                "//div[@class='maincontent']/div[@class='leftcol']/div[@class='arena-ctn cf']/a[@class='arena-ctn-itm left active']"))));
    } catch (Exception ex) {
        Logger.getLogger(SingleThread.class.getName()).log(Level.SEVERE, null, ex);
    }
    List<WebElement> list = driver.findElements(
            By.xpath("//div[@class='maincontent']/div[@class='leftcol']/div[@class='arena-ctn cf']/a"));
    for (WebElement arena : list) {
        if (arena.isDisplayed()) {
            arenas.add(arena.getText());
        }
    }
    return arenas;
}

From source file:de.betterform.conformance.WebDriverTestFunctions.java

License:BSD License

public boolean isControlPresent(String id, String type) {
    //TODO; Check type?
    try {//www.j ava  2  s  .c o  m
        WebElement control = webDriver.findElement(By.id(id));
        if (control.isDisplayed() || control.getAttribute("hidden").equals("true")) {
            return true;
        } else {
            return false;
        }

    } catch (NoSuchElementException nse) {
        //Do nothing.
    }
    return false;
}

From source file:de.codecentric.janus.plugin.step.BootstrapProject.java

License:Apache License

private void testScaffoldWith(WebElement option, String expDescription,
        Map<String, String> expRequiredContext) {
    testScaffoldWith(option, expDescription);

    for (Map.Entry<String, String> entry : expRequiredContext.entrySet()) {
        String selector = "input[name=\"" + entry.getKey() + "\"]";
        WebElement input = findByCSS(selector);
        assertThat(input.isDisplayed(), is(true));

        WebElement errorMsg = findByCSS(selector + " + div.error");
        assertThat(errorMsg.isDisplayed(), is(true));
    }//  w w  w. ja v  a  2s . co  m
}