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:backend.BackendLoginTest.java

@Test(description = "wfp backend setup", priority = 1)
public void frontendSetup() {
    driver.navigate().to("http://localhost:8082/workflow4people");
    WebDriverWait wait = new WebDriverWait(driver, 10);
    WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("j_username")));
}

From source file:bi.com.seleniumgrid.PhantomJsTest.java

License:Apache License

@Test
public void test() {
    final DesiredCapabilities capabilities = new DesiredCapabilities();
    // Configure our WebDriver to support JavaScript and be able to find the PhantomJS binary
    capabilities.setJavascriptEnabled(true);
    capabilities.setCapability("takesScreenshot", false);
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, PHANTOMJS_BINARY);
    final WebDriver driver = new PhantomJSDriver(capabilities);
    // Your test code here. For example:
    WebDriverWait wait = new WebDriverWait(driver, 30); // 30 seconds of timeout
    driver.get("https://en.wikipedia.org/wiki/Main_Page"); // navigate to Wikipedia

    pageTitle = driver.getTitle().trim();
    Assert.assertEquals(pageTitle, "GoalQuest");

    System.out.println("Page title is: " + driver.getTitle());

    By searchInput = By.id("searchInput"); // search for "Software"
    wait.until(ExpectedConditions.presenceOfElementLocated(searchInput));
    driver.findElement(searchInput).sendKeys("Software");
    By searchButton = By.id("searchButton");
    wait.until(ExpectedConditions.elementToBeClickable(searchButton));
    driver.findElement(searchButton).click();

    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.tagName("body"), "Computer software")); // assert that the resulting page contains a text
}

From source file:br.com.esign.logistics.test.selenium.page.HomePage.java

License:Open Source License

private void waitForElement(WebElement element) {
    WebDriverWait driverWait = new WebDriverWait(driver, 20);
    driverWait.until(ExpectedConditions.visibilityOf(element));
    driverWait.until(ExpectedConditions.elementToBeClickable(element));
}

From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebBase.java

License:Open Source License

private void waitClickable(By by) {
    findFrameContainingElement(by);//from   ww  w  .ja v  a2  s.  c  o  m

    // Faz a verificao no FRAME selecionado
    WebDriverWait wait = new WebDriverWait(getDriver(), (BehaveConfig.getRunner_ScreenMaxWait() / 1000));
    wait.until(ExpectedConditions.elementToBeClickable(by));
}

From source file:budget.util.java

public static void waitAndClick(WebDriver driver, WebDriverWait wait, By locator) {
    wait.until(ExpectedConditions.elementToBeClickable(locator));
    driver.findElement(locator).click();
}

From source file:budget.WebDriverManager.java

private static void refreshAccountsAmEx() {
    int attempts = 3;
    int attempt = 1;
    Boolean isDownloaded = false;
    List<String> credentials = getCredentials(7);

    while ((attempt <= attempts) && !isDownloaded) {
        try {/* w  w  w.j  a v a 2 s  .c  o m*/
            driver = new FirefoxDriver();
            driver.manage().window().setPosition(new Point(-2000, 0));
            wait = new WebDriverWait(driver, timeout);
            java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit")
                    .setLevel(java.util.logging.Level.OFF);
            java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF);

            driver.get("Http://www.americanexpress.com");
            driver.findElement(By.id("Username")).clear();
            driver.findElement(By.id("Username")).sendKeys(credentials.get(0));
            driver.findElement(By.id("Password")).clear();
            driver.findElement(By.id("Password")).sendKeys(credentials.get(1));
            driver.findElement(By.id("loginLink")).click();

            //Total amount       
            waitAndClick(driver, wait, By.id("avlbleCreditAsterick"));
            waitForElement(wait, By.id("availCreditValue"));
            String balanceStr = driver.findElement(By.id("availCreditValue")).getText();
            String limitStr = driver.findElement(By.id("ttlCreditValue")).getText();
            double amount = convertStringAmountToDouble(balanceStr) - convertStringAmountToDouble(limitStr);
            addTotal(stmt, getTimestamp(), 7, amount, taLog);

            //Transactions
            waitAndClick(driver, wait, By.id("MYCA_PC_Statements2"));
            waitAndClick(driver, wait, By.id("expandTP"));
            waitAndClick(driver, wait, By.id("anon_7"));//January 1 to Present
            wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.id("expandTP"))));

            //Pending transactions
            driver.findElement(By.id("recentTrans")).click();
            waitForElement(wait, By.className("pendingetd-helptxt"));
            runQueryAmEx(driver, wait, true);

            //Posted transactions
            runQueryAmEx(driver, wait, false);

            driver.findElement(By.id("iNLogBtn")).click();
            driver.quit();

            isDownloaded = true;
        } catch (Exception ex) {
            driver.quit();
            trace(ex.getMessage(), taLog);
            clearBatch(stmt);
            attempt++;
        }
        ;
    }
    trace((isDownloaded ? "Downloaded" : "Not downloaded") + " from " + attempt
            + ((attempt == 1) ? " attempt" : " attemps"), taLog);

    //Execution
    executeBatch(stmt, taLog);
}

From source file:budget.WebDriverManager.java

private static void runQueryAmEx(WebDriver driver, WebDriverWait wait, Boolean isPending) {
    String date;/*from w  w w. j  a  va2s. co m*/
    String Analytics;
    String Category;
    Double amount;

    List<WebElement> rows = driver.findElements(By.className((isPending) ? "pending-trans" : "posted-trans"));
    for (WebElement row : rows) {
        date = rotateDate(row.findElement(By.className("colDate")).getText().replace("\n*", ""), "MMMM\ndd");
        Analytics = prepareTextForQuery(row.findElement(By.className("desc-trans")).getText());
        amount = -convertStringAmountToDouble(row.findElement(By.className("colAmmount")).getText());
        if (amount < 0) {
            row.findElement(By.className("colPlus")).click();
            sleep(sleepTime);
            wait.until(ExpectedConditions.elementToBeClickable(row.findElement(By.className("printLink"))));
            Category = prepareTextForQuery(row.findElement(By.className("mobl_spanAddress")).getText());
            row.findElement(By.className("colPlus")).click();
        } else {
            Category = "";
        }
        addTransaction(true, stmt, date, 7, Category, Analytics, amount, isPending, taLog);
    }
}

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

License:Open Source License

public void clickFolder(String folderName) {
    WebElement folder = (new WebDriverWait(driver, 10)).until(ExpectedConditions.elementToBeClickable(
            xpath("//*[@id=\"beacon\"]/tbody/tr/td/a[text()[contains(.,'" + folderName + "')]]")));

    System.out.println("Folder to be clicked: " + folder.getText());
    folder.click();//from w ww .j av  a  2s . c  om
}

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

License:Open Source License

public void clickFolderForRow(int rowNum) throws Exception {
    WebElement firstCheckbox = (new WebDriverWait(driver, 10)).until(ExpectedConditions
            .elementToBeClickable(xpath("//*[@id=\"beacon\"]/tbody/tr[" + rowNum + "]/td[2]/a")));
    click(firstCheckbox);/*w  w  w  .j  av a 2  s. co  m*/
}

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

License:Open Source License

public void createNewFolder(String foldername) throws Exception {
    newdropdownButton.click();/*from   w w w  . j  ava 2s. c o m*/
    newFolder.click();
    WebElement newfolderInput = (new WebDriverWait(driver, 10))
            .until(ExpectedConditions.elementToBeClickable(By.id("fname")));

    sendKeys(newfolderInput, foldername);

    WebElement createFolderButton = find(xpath("//button[contains(text(),\"Create Folder\")]"));
    createFolderButton.click();

    if (isJqiMsgShowing(CONFIRMATION_MSG)) {
        clickButton(OK);
    } else {
        throw new Exception("Could not create folder " + foldername);
    }
}