Search in sources :

Example 51 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project iTest by e-government-ua.

the class CustomMethods method setTableCellsInputTypeString.

// Methods for filling the table for central
public void setTableCellsInputTypeString(WebDriver driver, String serviceName, String tableName, String cellName, String NameRow, String text) {
    WebElement td = driver.findElement(By.cssSelector("#field-" + tableName + " input[name=" + cellName + NameRow + "]"));
    new WebDriverWait(driver, 5).until(ExpectedConditions.elementToBeClickable(td));
    td.click();
    td.clear();
    td.sendKeys(text);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 52 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project iTest by e-government-ua.

the class CustomMethods method SetRegionFieldInputTypeLong.

public void SetRegionFieldInputTypeLong(WebDriver driver, String serviceName, String cssSelector, String value) {
    WebElement webElement = driver.findElement(By.cssSelector("input[name='" + cssSelector + "']"));
    new WebDriverWait(driver, 5).until(ExpectedConditions.elementToBeClickable(webElement));
    //        webElement.click();
    webElement.clear();
    webElement.sendKeys(value);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 53 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project iTest by e-government-ua.

the class CustomMethods method click.

public void click(WebDriver driver, WebElement webElement) {
    new WebDriverWait(driver, 5).until(ExpectedConditions.elementToBeClickable(webElement));
    webElement.click();
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 54 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project iTest by e-government-ua.

the class CustomMethods method getText.

//public void attachDocument(WebElement locator, String document, WebDriver driver) {
//}    
public String getText(WebDriver driver, WebElement webElement) throws Exception {
    new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOf(webElement));
    String answer = null;
    try {
        answer = webElement.getText();
    } catch (Exception e) {
        throw new Exception(e);
    }
    return answer;
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) IOException(java.io.IOException)

Example 55 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project nutch by apache.

the class DefaultClickAllAjaxLinksHandler method processDriver.

public String processDriver(WebDriver driver) {
    String accumulatedData = "";
    try {
        driver.findElement(By.tagName("body")).getAttribute("innerHTML");
        Configuration conf = NutchConfiguration.create();
        new WebDriverWait(driver, conf.getLong("libselenium.page.load.delay", 3));
        List<WebElement> atags = driver.findElements(By.tagName("a"));
        int numberofajaxlinks = atags.size();
        for (int i = 0; i < numberofajaxlinks; i++) {
            if (atags.get(i).getAttribute("href") != null && atags.get(i).getAttribute("href").equals("javascript:void(null);")) {
                atags.get(i).click();
                if (i == numberofajaxlinks - 1) {
                    // append everything to the driver in the last round
                    JavascriptExecutor jsx = (JavascriptExecutor) driver;
                    jsx.executeScript("document.body.innerHTML=document.body.innerHTML " + accumulatedData + ";");
                    continue;
                }
                accumulatedData += driver.findElement(By.tagName("body")).getAttribute("innerHTML");
                // refreshing the handlers as the page was interacted with
                driver.navigate().refresh();
                new WebDriverWait(driver, conf.getLong("libselenium.page.load.delay", 3));
                atags = driver.findElements(By.tagName("a"));
            }
        }
    } catch (Exception e) {
        LOG.info(StringUtils.stringifyException(e));
    }
    return accumulatedData;
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) NutchConfiguration(org.apache.nutch.util.NutchConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement)

Aggregations

WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)527 WebElement (org.openqa.selenium.WebElement)166 WebDriver (org.openqa.selenium.WebDriver)131 Test (org.junit.Test)86 By (org.openqa.selenium.By)54 Actions (org.openqa.selenium.interactions.Actions)53 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)43 TimeoutException (org.openqa.selenium.TimeoutException)38 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)36 IOException (java.io.IOException)28 List (java.util.List)26 Wait (org.openqa.selenium.support.ui.Wait)25 BeforeClass (org.junit.BeforeClass)24 NgWebDriver (com.github.sergueik.jprotractor.NgWebDriver)21 ArrayList (java.util.ArrayList)21 WebDriverException (org.openqa.selenium.WebDriverException)21 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)21 Dimension (org.openqa.selenium.Dimension)20 File (java.io.File)16 NoSuchElementException (org.openqa.selenium.NoSuchElementException)16