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:ca.nrc.cadc.UserStorageBrowserPage.java

License:Open Source License

public String togglePublicAttributeForRow(int rowNum) throws Exception {
    String currentPermission = "";
    WebElement editIcon = find(xpath("//span[contains(@class, 'glyphicon-edit')]"));
    editIcon.click();//from www  .  j av a  2  s  .  c  o  m
    WebElement permissionCheckbox = (new WebDriverWait(driver, 10))
            .until(ExpectedConditions.elementToBeClickable(By.id("publicPermission")));

    currentPermission = permissionCheckbox.getAttribute("checked");
    click(permissionCheckbox);
    clickButton(SAVE);

    // confirm folder delete
    if (isJqiMsgShowing(SUCCESSFUL)) {
        clickButton(OK);
    } else {
        throw new Exception("Permissions editing not successful for row : " + rowNum);
    }

    return currentPermission;
}

From source file:ca.nrc.cadc.UserStorageBrowserPage.java

License:Open Source License

public void clickCheckboxForRow(int rowNum) throws Exception {
    WebElement firstCheckbox = (new WebDriverWait(driver, 10)).until(ExpectedConditions
            .elementToBeClickable(xpath("//*[@id=\"beacon\"]/tbody/tr[" + rowNum + "]/td[1]")));
    click(firstCheckbox);/*from   ww  w . ja va 2 s. c  o m*/
}

From source file:ca.nrc.cadc.UserStorageBrowserPage.java

License:Open Source License

public boolean isJqiMsgShowing(String message) {
    try {// www . j a  va2s .  c om
        WebElement jqiMsg = (new WebDriverWait(driver, 10)).until(ExpectedConditions.elementToBeClickable(
                xpath("//div[contains(@class, \"jqimessage\") and contains(text(), \"" + message + "\")]")));
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:ca.nrc.cadc.UserStorageBrowserPage.java

License:Open Source License

public boolean isJqiColourMsgShowing(String message) {
    try {//from  ww w . j  a v  a2s  . com
        WebElement jqiMsg = (new WebDriverWait(driver, 10)).until(ExpectedConditions.elementToBeClickable(
                xpath("//div[contains(@class, 'jqimessage')]/span[contains(text(), '" + message + "')]")));
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:ca.nrc.cadc.web.selenium.AbstractTestWebPage.java

License:Open Source License

public void waitForElementClickable(final WebElement element) throws Exception {
    assert (waitUntil(ExpectedConditions.elementToBeClickable(element)) != null);
}

From source file:ca.pe.cjsigouin.testinator.selenium.WebDriverMain.java

public static void main(String[] args) {

    System.setProperty("webdriver.gecko.driver", "/home/krystofurr/Programs/selenium/geckodriver");
    System.setProperty("webdriver.chrome.driver", "/home/krystofurr/Programs/selenium/chromedriver");

    //     WebDriver driver = new FirefoxDriver();
    WebDriver driver = new ChromeDriver();
    //     WebDriver driver = new InternetExplorerDriver();

    //Puts an Implicit wait, Will wait for 10 seconds before throwing exception
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    //Launch website
    driver.navigate().to(CommonConstants.HOST + CommonConstants.URL_LOGIN);

    driver.findElement(By.id("emailAddress")).sendKeys("cjsigouin@gov.pe.ca");
    driver.findElement(By.id("password")).sendKeys("Test12345!");
    driver.findElement(By.id("loginButton")).click();

    WebDriverWait wait = new WebDriverWait(driver, 5);
    wait.until(/*from  w w w  .  ja v a2s .  c  om*/
            ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='serviceWellSection']/div[2]/div/a/b")));

    driver.get(CommonConstants.HOST + CommonConstants.URL_RESERVE_NAME_INTRO);
    WebDriverWait wait2 = new WebDriverWait(driver, 5);

    wait2.until(ExpectedConditions.elementToBeClickable(By.xpath(ReserveNameElement.INTRO_BUTTON_CANCEL)));
    driver.findElement(By.xpath(ReserveNameElement.INTRO_RADIO_RESERVE_NAME)).click();
    //     driver.findElement(By.xpath(ReserveNameElement.INTRO_SELECT_COMPANY_TYPE)).sendKeys("Incorp");

    Select dropdown = new Select(driver.findElement(By.xpath(ReserveNameElement.INTRO_SELECT_COMPANY_TYPE)));
    dropdown.selectByVisibleText("Incorporated");
    driver.findElement(By.xpath(ReserveNameElement.INTRO_BUTTON_NEXT)).click();

    //     WebDriver driver = new FirefoxDriver();
    //     LoginTester login = new LoginTester(driver);
    //     IncorporatedTester tester = new IncorporatedTester(driver);
    //
    //     login.start();

    //     //Maximize the browser
    //     driver.manage().window().maximize();
    //     tester.start();
    //     tester.stop();

    //     // Click on Math Calculators
    //     driver.findElement(By.xpath(".//*[@id='hcalc']/table/tbody/tr/td[2]/div[3]/a")).click();
    //     
    //     // Click on Percent Calculators
    //     driver.findElement(By.xpath(".//*[@id='content']/ul[1]/li[3]/a")).click();
    //     
    //     // Enter value 10 in the first number of the percent Calculator
    //     driver.findElement(By.id("cpar1")).sendKeys(data.getNumberText(2));
    //     
    //     // Enter value 50 in the second number of the percent Calculator
    //     driver.findElement(By.id("cpar2")).sendKeys(data.getNumberText(2));
    //     
    //     // Click Calculate Button
    //     driver.findElement(By.xpath(".//*[@id='content']/table[1]/tbody/tr[2]/td/input[2]")).click();
    //   
    //     
    //     // Get the Result Text based on its xpath
    //     String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/font/b")).getText();
    //   
    //     
    //     // Print a Log In message to the screen
    //     System.out.println(" The Result is " + result);

    //Close the Browser.
    driver.close();
}

From source file:ch.vorburger.vaadin.designer.tests.web.DesignerWebDriverTest.java

License:Apache License

@BeforeClass
public static void setUpClass() throws Exception {
    // This is needed (only) for stand-alone EMF initialization
    SamplescreenPackage.eINSTANCE.eClass();

    final String path = "/ch/vorburger/vaadin/designer/samplescreen/screen1.xmi";
    URL url = DesignerWebDriverTest.class.getResource(path);
    if (url == null)
        throw new IOException("Could not getResource() for " + path);
    screen = new EIO().load(URI.createURI(url.toString()), Screen.class);

    driver = newWebDriver();/* www .  j  a  v a  2  s.  c  o  m*/
    wait = new WebDriverWait(driver, 10);
    action = new Actions(driver);

    server = new DesignerServer();

    server.start();

    root = new SampleFixedScreenComponent();
    new SampleFixedScreenBinding().bind(root, screen);
    server.getDesignerApplication().setRootContent(root);

    driver.get(server.getURL());
    wait.until(ExpectedConditions.elementToBeClickable(By.id("name")));
}

From source file:com.atanas.kanchev.testframework.selenium.handlers.Wait.java

License:Apache License

/**
 * {@inheritDoc}/* w  w  w. jav  a 2 s.  co m*/
 */
@Override
public boolean isElementClickable(By locator, long wait) {

    try {
        getWait(wait).until(ExpectedConditions.elementToBeClickable(locator));
        return true;
    } catch (TimeoutException e) {
        logger.error("Timeout after waiting for element to be clickable located by:  " + locator.toString());
        throw new TimeoutException(e.getMessage());
    }

}

From source file:com.autocognite.appium.lib.base.AbstractAppiumUiDriver.java

License:Apache License

public void waitForElementClickability(By findBy) throws Exception {
    getWaiter().until(ExpectedConditions.elementToBeClickable(findBy));
}

From source file:com.autocognite.appium.lib.base.AbstractAppiumUiDriver.java

License:Apache License

public void waitForElementClickability(WebElement element) throws Exception {
    getWaiter().until(ExpectedConditions.elementToBeClickable(element));
}