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

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

Introduction

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

Prototype

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

Source Link

Document

An expectation for checking an element is visible and enabled such that you can click it.

Usage

From source file:com.gwtplatform.carstore.cucumber.application.BasePage.java

License:Apache License

protected WebElement waitUntilElementIsClickable(By locator) {
    moveToElementLocatedBy(locator);

    return webDriverWait().until(ExpectedConditions.elementToBeClickable(locator));
}

From source file:com.hotwire.selenium.desktop.us.billing.ActivitiesFragment.java

License:Open Source License

public boolean verifyMoreDetailsLinks() {

    // Iterate through all more details links and click them to see if ds
    // popup is invoked.
    for (WebElement element : moreDetails) {
        try {/*w w  w . ja  v a2 s . c o m*/
            if (element.isDisplayed()) {
                element.click();
                if (!dsPopUp.isDisplayed()) {
                    return false;
                } else {
                    //if ds popup is opened, close it.
                    new Wait<>(ExpectedConditions
                            .elementToBeClickable(By.xpath("//div[@class='yui-panel-container shadow']/div/a")))
                                    .maxWait(3).apply(getWebDriver()).click();
                }
            } else {
                return false;
            }
        } catch (NoSuchElementException e) {
            logger.info("Element - More details links and/or DS pop-up, don't appear.");
        }
    }

    return true;
}

From source file:com.hotwire.selenium.desktop.us.billing.car.impl.ccf.CcfDetailsFragment.java

License:Open Source License

@Override
public CarSolutionModel getCarOptionsSet() {
    CarSolutionModel sm = new CarSolutionModel();
    /**/* w  w w. j  a  v a2  s. c  o m*/
     * Wait while block will be loaded
     */
    new WebDriverWait(getWebDriver(), MAX_SEARCH_PAGE_WAIT_SECONDS)
            .until(ExpectedConditions.elementToBeClickable(By.cssSelector(CSS_VENDOR)));

    sm.setPerDayPrice(getPerDayPrice());
    sm.setTotalPrice(getTotalPrice());
    sm.setCurrency(getCurrency());
    sm.setVendor(getVendor());
    return sm;
}

From source file:com.hotwire.selenium.desktop.us.billing.onepage.HotelVmeFragment.java

License:Open Source License

public void fillVmePaymentMethodPanel(String username, String password) {

    // Choose Vme as payment method
    this.vmePaymentTypeRadioButton.click();

    // Click the Vme buy button to launch the lightbox
    this.vmeBuyButton.click();

    // Switch to the lightbox iframe
    getWebDriver().switchTo().frame(this.vmeIframe);

    new WebDriverWait(getWebDriver(), DEFAULT_WAIT)
            .until(PageObjectUtils.webElementVisibleTestFunction(By.id(USERNAME_ID), true));
    getWebDriver().findElement(By.id(USERNAME_ID)).clear();
    getWebDriver().findElement(By.id(USERNAME_ID)).sendKeys(username);
    getWebDriver().findElement(By.id(PASSWORD_ID)).clear();
    getWebDriver().findElement(By.id(PASSWORD_ID)).sendKeys(password);

    getWebDriver().findElement(By.cssSelector(SIGN_IN_BUTTON_ID)).click();
    // We assume sign in was successful here...

    // Switch to the main billing window
    getWebDriver().switchTo().defaultContent();
    // Switch to the lightbox iframe
    getWebDriver().switchTo().frame(this.vmeIframe);
    WebDriverWait wait = new WebDriverWait(getWebDriver(), DEFAULT_WAIT);
    wait.until(ExpectedConditions.elementToBeClickable(By.xpath(CONTINUE_BUTTON_XPATH))).click();

    // Done interacting with lightbox, switch back to main billing window
    getWebDriver().switchTo().defaultContent();

    // Wait for the lightbox to go away
    wait = new WebDriverWait(getWebDriver(), DEFAULT_WAIT);
    wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(LIGHTBOX_IFRAME_XPATH)));
}

From source file:com.hotwire.selenium.desktop.us.details.AirDetailsPage.java

License:Open Source License

public void addRentalCar() {
    if (isRentalCarOptionLinkAvailable()) {
        rentalCarOption.click();/*from  w  w  w  . j  av a2s .c om*/
        new WebDriverWait(getWebDriver(), getTimeout())
                .until(ExpectedConditions.elementToBeClickable(By.name("selectedCarAddOnSolutionId"))).click();
    } else {
        throw new RuntimeException("Can't rent a car as add-on for flight.. The link didn't appear");
    }
}

From source file:com.hotwire.selenium.tools.c3.purchase.car.C3CarAddonPage.java

License:Open Source License

public void addRentalCar() {
    if (isRentalCarOptionLinkAvailable()) {
        findOne(".startSearch>span", DEFAULT_WAIT).click();
        new WebDriverWait(getWebDriver(), getTimeout())
                .until(ExpectedConditions.elementToBeClickable(By.name("selectedCarAddOnSolutionId"))).click();
    } else {//from ww  w. j a  v  a  2s.c o  m
        throw new RuntimeException("Can't rent a car as add-on for flight.. The link didn't appear");
    }
}

From source file:com.hp.test.framework.jelly.WaitUntilElementClickableTag.java

@Override
public void doTag(XMLOutput arg0) throws MissingAttributeException, JellyTagException {
    logger.info("Started Execution of WaitUntilElementClickable function");
    WebDriver driver = getSelenium();/*www. jav a2 s  .c  o  m*/
    int loc = id.indexOf("=");

    String locator = id.substring(loc + 1);
    String bylocator = id.substring(0, loc);
    System.out.println("locator" + locator);
    System.out.println("id" + bylocator);
    switch (bylocator) {
    case "id": {
        try {
            System.out.println("Executing case id");
            WebDriverWait wait = new WebDriverWait(driver, 300);
            WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id(locator)));
        } catch (TimeoutException e) {
            System.out.println("TimeOut Exception" + "\n" + e.getMessage());
        }
        break;
    }

    case "name": {
        try {
            System.out.println("Executing case name");
            WebDriverWait wait = new WebDriverWait(driver, 300);
            WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.name(locator)));
        } catch (TimeoutException e) {
            System.out.println("TimeOut Exception" + "\n" + e.getMessage());
        }
        break;
    }

    case "xpath": {
        try {
            System.out.println("Executing case xpath");
            WebDriverWait wait = new WebDriverWait(driver, 300);
            WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator)));
        } catch (TimeoutException e) {
            System.out.println("TimeOut Exception" + "\n" + e.getMessage());
        }
        break;
    }

    case "css": {
        try {
            System.out.println("identify element with CSS path and click");
            WebDriverWait wait = new WebDriverWait(driver, 300);
            WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(locator)));
        } catch (TimeoutException e) {
            System.out.println("TimeOut Exception" + "\n" + e.getMessage());

            break;
        }
    }

        try {
            Thread.sleep(5000);

        } catch (InterruptedException e) {

        }
        logger.info("Completed Execution of WaitUntilElementClickable function");
    }

}

From source file:com.ibm.sbt.automation.core.test.pageobjects.VCardResultPage.java

License:Open Source License

/**
 * This method hovers over the card's attach point and then clicks the hover menu which appears. This should bring up the VCard.
 * //from   w w  w. j  a va  2  s  .  c  om
 * @return True if the ProfileCard appeared, false if not.
 */
public boolean isProfileCardDisplayable(WebElement cardAttachPoint) {
    WebDriver driver = getWebDriver();

    new Actions(driver).moveToElement(cardAttachPoint).perform(); // hover over the attachpoint to make the semtagmenu appear.

    WebDriverWait wait = new WebDriverWait(driver, 5);
    WebElement semtagmenu = wait.until(ExpectedConditions.elementToBeClickable(By.id("semtagmenu"))); // wait until the hover menu is clickable.

    WebElement semTagHoverMenu = semtagmenu.findElement(By.xpath(".//a"));
    new Actions(driver).click(semTagHoverMenu).perform(); // click the hovering menu
    WebElement vCardDiv = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cardDiv")));

    return vCardDiv.isDisplayed();
}

From source file:com.ibm.watson.app.qaclassifier.selenium.drivers.SkipWelcomeScreenRule.java

License:Open Source License

private void skipWelcomeScreen() throws InterruptedException {
    WebDriver driver = driverRef.get();/*from  w w w . j  av  a2s.c om*/
    // In some cases on Internet Explorer it can take more than five seconds for this to appear.
    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.id("actionButton")));
    WebElement actionButton = driver.findElement(By.id("actionButton"));
    actionButton.click();
}

From source file:com.ionidea.RegressionNGA.Tests.FooterTest.java

License:Open Source License

/**
 * the method verifies that the opened page is respective to the used sub menu option
 * @param url //from   ww  w. ja  v a2s . c  o m
 * @param link
 */

public void verifyFooterLinks(String url, WebElement link) throws InterruptedException {
    driver.get(m_baseUrl);
    String mainHandle = driver.getWindowHandle();

    //Click on the link
    m_wait.until(ExpectedConditions.elementToBeClickable(link));
    link.click();
    //create excplicite wait 
    Thread.sleep(2000);
    if (url == "https://www.google.com/maps/place/Constitution+Ave+") {
        for (String winHandle : driver.getWindowHandles()) {
            driver.switchTo().window(winHandle);
            if (driver.getCurrentUrl().contains("https://www.google.com/maps/place/Constitution+Ave+")) {
                ;
                driver.close();
                driver.switchTo().window(mainHandle);
                break;
            }
        }
    } else {
        //WebDriverWait wait = new WebDriverWait(driver,30000);
        m_wait.until(ExpectedConditions.urlContains(url));
        //verify URL and title of the opened page
        Assert.assertTrue(driver.getCurrentUrl().contains(url));
    }
}