Example usage for org.openqa.selenium.support.ui ExpectedConditions visibilityOf

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOf

Introduction

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

Prototype

public static ExpectedCondition<WebElement> visibilityOf(final WebElement element) 

Source Link

Document

An expectation for checking that an element, known to be present on the DOM of a page, is visible.

Usage

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public WebElement waitForElementVisible(final WebElement element, int timeOut) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), timeOut);
    wait.until(ExpectedConditions.visibilityOf(element));
    return element;
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public List<WebElement> waitAndFindElements(By by) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), DRIVER_WAIT_TIME);
    wait.until(ExpectedConditions.visibilityOf(getDriver().findElement(by)));
    return getDriver().findElements(by);
}

From source file:test.TestCreation.java

License:Open Source License

@Before
public void createAlarm() {
    TestScenario.navigation.clickOnAddAlarm();
    //Enter alarm name
    WebElement name = driver.findElement(By.name("name"));
    name.sendKeys(NAME);/*from ww w . j a  va  2 s  .  c  o  m*/
    LOGGER.info("Enter alarm name");

    //Enter alarm description
    WebElement description = driver.findElement(By.name("description"));
    description.sendKeys(DESCRIPTION);
    LOGGER.info("Enter alarm description");

    //enter alarm graphite key
    WebElement key = driver.findElement(By.name("graphite-key"));
    key.sendKeys(GRAPHITE_KEY);
    LOGGER.info("Enter alarm graphite key");

    //go to step 2
    Utils.clickWhenReady(driver, By.name("go-to-step-2"));
    LOGGER.info("go to step 2");

    //change windowMode
    Select windowModes = new Select(driver.findElement(By.id("windowMode")));
    List<WebElement> options = windowModes.getOptions();
    for (WebElement option : options) {
        option.click();
        String value = option.getAttribute("value");
        if (value.equalsIgnoreCase("summarize")) {
            assertTrue(driver.findElement(By.id("windowAggregation")).isDisplayed());
            assertTrue(driver.findElement(By.id("timeUnitsNumber")).isDisplayed());
            assertTrue(driver.findElement(By.id("windowUnits")).isDisplayed());
        }
    }
    LOGGER.info("try all windowModes");

    //go to step 3
    Utils.clickWhenReady(driver, By.name("go-to-step-3"));
    LOGGER.info("go to step 3");

    //Enter warn Threshold
    WebElement warnThreshold = driver.findElement(By.name("warn-threshold"));
    warnThreshold.sendKeys(WARN_THRESHOLD);
    LOGGER.info("Enter warning threshold");

    //Enter error Threshold
    WebElement errorThreshold = driver.findElement(By.name("error-threshold"));
    errorThreshold.sendKeys(ERROR_THRESHOLD);
    LOGGER.info("Enter error threshold");

    //go to step 4
    Utils.clickWhenReady(driver, By.id("go-to-step-4"));
    LOGGER.info("Go to step 4");

    //go to step 5
    Utils.clickWhenReady(driver, By.id("go-to-step-5"));
    LOGGER.info("Go to step 5");

    //create alarm
    new WebDriverWait(driver, Utils.DEFAULT_WAITING_TIME)
            .until(ExpectedConditions.visibilityOf(driver.findElement(By.id("confirm-alarm-creation"))));
    Utils.clickWhenReady(driver, By.id("confirm-alarm-creation"));

    //wait redirect
    new WebDriverWait(driver, Utils.DEFAULT_WAITING_TIME)
            .until(ExpectedConditions.visibilityOfElementLocated(By.id("alarm-name-title")));
    LOGGER.info("alarm is created");
}

From source file:test.TestNavigation.java

License:Open Source License

public void searchAlarm() {
    TestScenario.navigation.clickOnAllAlarms();
    WebElement searchBar = driver.findElement(By.id("filterBarText"));
    new WebDriverWait(driver, Utils.DEFAULT_WAITING_TIME).until(ExpectedConditions.visibilityOf(searchBar));
    Utils.clickWhenReady(driver, By.id("showDisableCheck"));
    LOGGER.info("show disabled alarms");
    Utils.clickWhenReady(driver, searchBar);
    searchBar.sendKeys(TestCreation.NAME);
    LOGGER.info("Search for '" + TestCreation.NAME + "'");
}

From source file:test.TestSubscription.java

License:Open Source License

public void unsubscribe() {
    TestScenario.navigation.clickOnMyAlarms();

    Utils.clickWhenReady(driver, driver.findElements(By.name("alarm-row")).get(0));
    LOGGER.info("Click on available alarm");
    if (TestScenario.useKeycloak) {
        Utils.clickWhenReady(driver, By.id("dashboard-details-alarm"));
    } else {/*ww w  . j  ava  2s .  co  m*/
        Utils.clickWhenReady(driver, By.id("alarms-details-alarm"));
    }
    LOGGER.info("Open alarm details");
    new WebDriverWait(driver, Utils.DEFAULT_WAITING_TIME)
            .until(ExpectedConditions.visibilityOf(driver.findElement(By.id("alarm-name-title"))));
    Utils.clickWhenReady(driver, driver.findElements(By.name("disable-subscription")).get(0));
    LOGGER.info("disable alarm subscription");
    new WebDriverWait(driver, Utils.DEFAULT_WAITING_TIME).until(
            ExpectedConditions.visibilityOf(driver.findElements(By.name("enabled-subscription")).get(0)));
}

From source file:test.TestSubscription.java

License:Open Source License

public void subscribe() {
    TestScenario.navigation.searchAlarm();
    new WebDriverWait(driver, Utils.DEFAULT_WAITING_TIME).until(ExpectedConditions.visibilityOf(
            driver.findElement(By.xpath("//div[@name='alarm-row' and text()[contains(.,'Selenium test')]]"))));
    Utils.clickWhenReady(driver, driver.findElements(By.name("alarm-row")).get(0));
    LOGGER.info("click on alarm");
    Utils.clickWhenReady(driver, By.id("alarms-details-alarm"));
    LOGGER.info("Open alarm details");
    Utils.clickWhenReady(driver, driver.findElements(By.name("enabled-subscription")).get(0));
    TestScenario.navigation.clickOnMyAlarms();
    LOGGER.info("go on 'my alarms' tab");
    Utils.clickWhenReady(driver, driver.findElements(By.name("alarm-row")).get(0));
    if (TestScenario.useKeycloak) {
        Utils.clickWhenReady(driver, By.id("dashboard-details-alarm"));
    } else {/*  ww w.jav a 2s. co m*/
        Utils.clickWhenReady(driver, By.id("alarms-details-alarm"));
    }
}

From source file:ui_Layer.LicencesPage.java

public void searchLicences(String searchValue) {
    wait.until(ExpectedConditions.elementToBeClickable(openSearchOption));
    openSearchOption.click();/*w ww.j a v a2s . co m*/
    wait.until(ExpectedConditions.visibilityOf(searchFiled)).sendKeys(searchValue);
    waitSleep(500);
}

From source file:ui_Layer.LicencesPage.java

public void clickAddLicenceBtn() {
    wait.until(ExpectedConditions.visibilityOf(addLicenceBtn)).click();
}

From source file:ui_Layer.LicencesPage.java

public void clickSelectVehicle() {
    wait.until(ExpectedConditions.visibilityOf(selectVehicleLink)).click();
}

From source file:ui_Layer.LicencesPage.java

public void choseVehicle(String vehicleValue) {
    wait.until(ExpectedConditions.visibilityOf(inputVehicleField));
    inputVehicleField.sendKeys(vehicleValue);
    waitSleep(5000);//from   www. j  a  va 2 s.  co m
    for (WebElement element : vehicleList) {
        if (element.getText().equals(vehicleValue)) {
            element.click();
        }
    }
}