Search in sources :

Example 41 with WebDriver

use of org.openqa.selenium.WebDriver in project java.webdriver by sayems.

the class LoadCookieInfo method main.

public static void main(String... args) {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.facebook.com");
    try {
        File f2 = new File("browser.data");
        FileReader fr = new FileReader(f2);
        BufferedReader br = new BufferedReader(fr);
        String line;
        while ((line = br.readLine()) != null) {
            StringTokenizer str = new StringTokenizer(line, ";");
            while (str.hasMoreTokens()) {
                String name = str.nextToken();
                String value = str.nextToken();
                String domain = str.nextToken();
                String path = str.nextToken();
                Date expiry = null;
                String dt;
                if (!(dt = str.nextToken()).equals("null")) {
                    expiry = new Date(dt);
                }
                boolean isSecure = new Boolean(str.nextToken()).booleanValue();
                Cookie ck = new Cookie(name, value, domain, path, expiry, isSecure);
                driver.manage().addCookie(ck);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    driver.get("http://www.facebook.com");
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Cookie(org.openqa.selenium.Cookie) StringTokenizer(java.util.StringTokenizer) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) Date(java.util.Date)

Example 42 with WebDriver

use of org.openqa.selenium.WebDriver in project java.webdriver by sayems.

the class GetHeight method main.

public static void main(String[] args) {
    WebDriver driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.navigate().to("http://www.google.com");
    driver.manage().window().setSize(new Dimension(1024, 768));
    driver.quit();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Dimension(org.openqa.selenium.Dimension) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 43 with WebDriver

use of org.openqa.selenium.WebDriver in project java.webdriver by sayems.

the class ClickOnWebElement2 method main.

public static void main(String... args) {
    WebDriver driver = new FirefoxDriver();
    driver.get("file://C:/Selectable.html");
    WebElement one = driver.findElement(By.name("one"));
    WebElement eleven = driver.findElement(By.name("eleven"));
    WebElement five = driver.findElement(By.name("five"));
    Actions builder = new Actions(driver);
    // Click on One, Eleven and Five
    builder.click(one).click(eleven).click(five);
    builder.build().perform();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement)

Example 44 with WebDriver

use of org.openqa.selenium.WebDriver in project java.webdriver by sayems.

the class ContextClick method main.

public static void main(String... args) {
    WebDriver driver = new FirefoxDriver();
    driver.get("file://C:/ContextClick.html");
    WebElement contextMenu = driver.findElement(By.id("div-context"));
    Actions builder = new Actions(driver);
    builder.contextClick(contextMenu).click(driver.findElement(By.name("Item 4"))).perform();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement)

Example 45 with WebDriver

use of org.openqa.selenium.WebDriver in project java.webdriver by sayems.

the class DoubleClick2 method main.

public static void main(String... args) {
    WebDriver driver = new FirefoxDriver();
    driver.get("file://C:/DoubleClick.html");
    WebElement dblClick = driver.findElement(By.name("dblClick"));
    Actions builder = new Actions(driver);
    builder.moveToElement(dblClick).doubleClick().perform();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement)

Aggregations

WebDriver (org.openqa.selenium.WebDriver)167 WebElement (org.openqa.selenium.WebElement)87 Test (org.junit.Test)61 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)59 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)40 Actions (org.openqa.selenium.interactions.Actions)25 IOException (java.io.IOException)12 Cookie (org.openqa.selenium.Cookie)11 List (java.util.List)10 File (java.io.File)9 HttpRequestCallback (ghostdriver.server.HttpRequestCallback)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)8 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)7 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)7 By (org.openqa.selenium.By)5 Dimension (org.openqa.selenium.Dimension)5 Predicate (com.google.common.base.Predicate)4 TimeoutException (org.openqa.selenium.TimeoutException)4