Search in sources :

Example 11 with WebDriver

use of org.openqa.selenium.WebDriver in project ghostdriver by detro.

the class MouseCommandsTest method doubleClick.

@Test
public void doubleClick() {
    WebDriver d = getDriver();
    Actions actionBuilder = new Actions(d);
    d.get("http://www.duckduckgo.com");
    // Double click
    actionBuilder.doubleClick().build().perform();
    // Double click on the logo
    actionBuilder.doubleClick(d.findElement(By.id("logo_homepage_link"))).build().perform();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Actions(org.openqa.selenium.interactions.Actions) Test(org.junit.Test)

Example 12 with WebDriver

use of org.openqa.selenium.WebDriver in project ghostdriver by detro.

the class MouseCommandsTest method clickAndHold.

@Test
public void clickAndHold() {
    WebDriver d = getDriver();
    Actions actionBuilder = new Actions(d);
    d.get("http://www.duckduckgo.com");
    // Hold, then release
    actionBuilder.clickAndHold().build().perform();
    actionBuilder.release();
    // Hold on the logo, then release
    actionBuilder.clickAndHold(d.findElement(By.id("logo_homepage_link"))).build().perform();
    actionBuilder.release();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Actions(org.openqa.selenium.interactions.Actions) Test(org.junit.Test)

Example 13 with WebDriver

use of org.openqa.selenium.WebDriver in project ghostdriver by detro.

the class NavigationTest method navigateToGoogleAdwords.

@Test
public void navigateToGoogleAdwords() {
    WebDriver d = getDriver();
    d.get("http://adwords.google.com");
    assertTrue(d.getCurrentUrl().contains("google.com"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test)

Example 14 with WebDriver

use of org.openqa.selenium.WebDriver in project ghostdriver by detro.

the class ElementMethodsTest method shouldNotHandleCasesWhenAsyncJavascriptInitiatesAPageLoadFarInTheFuture.

@Test
public void shouldNotHandleCasesWhenAsyncJavascriptInitiatesAPageLoadFarInTheFuture() {
    server.setHttpHandler("GET", new HttpRequestCallback() {

        @Override
        public void call(HttpServletRequest req, HttpServletResponse res) throws IOException {
            res.getOutputStream().println("<script type=\"text/javascript\">\n" + "    function myFunction() {\n" + "        setTimeout(function() {\n" + "            window.location.href = 'http://www.google.com';\n" + "        }, 5000);\n" + "    }\n" + "    </script>\n" + "    <a onclick=\"javascript: myFunction();\">Click Here</a>");
        }
    });
    WebDriver d = getDriver();
    d.get(server.getBaseUrl());
    // Initiate timer that will finish with loading Google in the window
    d.findElement(By.xpath("html/body/a")).click();
    // "google.com" hasn't loaded yet at this stage
    assertFalse(d.getTitle().toLowerCase().contains("google"));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WebDriver(org.openqa.selenium.WebDriver) HttpRequestCallback(ghostdriver.server.HttpRequestCallback) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) Test(org.junit.Test)

Example 15 with WebDriver

use of org.openqa.selenium.WebDriver in project ghostdriver by detro.

the class ElementMethodsTest method checkEnabledOnGoogleSearchBox.

@Test
public void checkEnabledOnGoogleSearchBox() {
    // TODO: Find a sample site that has hidden elements and use it to
    // verify behavior of enabled and disabled elements.
    WebDriver d = getDriver();
    d.get("http://www.google.com");
    WebElement el = d.findElement(By.cssSelector("input[name*='q']"));
    assertTrue(el.isEnabled());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

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