use of org.openqa.selenium.WebDriver in project ghostdriver by detro.
the class ScriptExecutionTest method shouldBeAbleToPassMultipleArgumentsToAsyncScripts.
@Test
public void shouldBeAbleToPassMultipleArgumentsToAsyncScripts() {
WebDriver d = getDriver();
d.manage().timeouts().setScriptTimeout(0, TimeUnit.MILLISECONDS);
d.get("http://www.google.com/");
Number result = (Number) ((JavascriptExecutor) d).executeAsyncScript("arguments[arguments.length - 1](arguments[0] + arguments[1]);", 1, 2);
assertEquals(3, result.intValue());
// Verify that a future navigation does not cause the driver to have problems.
d.get("http://www.google.com/");
}
use of org.openqa.selenium.WebDriver in project ghostdriver by detro.
the class SessionBasicTest method closeShouldNotTerminatePhantomJSProcess.
@Test(expected = NoSuchWindowException.class)
public void closeShouldNotTerminatePhantomJSProcess() throws MalformedURLException {
// By default, 1 window is created when Driver is launched
WebDriver d = getDriver();
assertEquals(1, d.getWindowHandles().size());
// Check the number of windows
d.navigate().to("about:blank");
assertEquals(1, d.getWindowHandles().size());
// Create a new window
((JavascriptExecutor) d).executeScript("window.open('http://www.google.com','google');");
assertEquals(2, d.getWindowHandles().size());
// Close 1 window and check that 1 is left
d.close();
assertEquals(1, d.getWindowHandles().size());
// Switch to that window
d.switchTo().window("google");
assertNotNull(d.getWindowHandle());
// Close the remaining window and check now there are no windows available
d.close();
assertEquals(0, d.getWindowHandles().size());
// This should throw a "NoSuchWindowException": the Driver is still running, but no Session/Window are left
d.getWindowHandle();
}
use of org.openqa.selenium.WebDriver in project ghostdriver by detro.
the class TimeoutSettingTest method navigateAroundMDN.
@Test
public void navigateAroundMDN() {
WebDriver d = getDriver();
d.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
d.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
d.manage().timeouts().setScriptTimeout(5, TimeUnit.SECONDS);
}
use of org.openqa.selenium.WebDriver in project ghostdriver by detro.
the class ElementJQueryEventsTest method shouldBeAbleToClickAndEventsBubbleUpUsingJquery.
@Test
public void shouldBeAbleToClickAndEventsBubbleUpUsingJquery() {
final String buttonId = "clickme";
server.setHttpHandler("GET", new HttpRequestCallback() {
@Override
public void call(HttpServletRequest req, HttpServletResponse res) throws IOException {
res.getOutputStream().println("<html>\n" + "<head>\n" + "<script src=\"//ajax.googleapis.com/ajax/libs/jquery/" + mJqueryVersion + "/jquery.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + " var clicked = false;" + " $(document).ready(function() {" + " $('#" + buttonId + "').bind('click', function(e) {" + " clicked = true;" + " });" + " });\n" + "</script>\n" + "</head>\n" + "<body>\n" + " <a href='#' id='" + buttonId + "'>click me</a>\n" + "</body>\n" + "</html>");
}
});
WebDriver d = getDriver();
d.get(server.getBaseUrl());
// Click on the link inside the page
d.findElement(By.id(buttonId)).click();
// Check element was clicked as expected
assertTrue((Boolean) ((JavascriptExecutor) d).executeScript("return clicked;"));
}
use of org.openqa.selenium.WebDriver in project ghostdriver by detro.
the class ElementMethodsTest method checkClickOnAHREFCausesPageLoad.
@Test
public void checkClickOnAHREFCausesPageLoad() {
WebDriver d = getDriver();
d.get("http://www.google.com");
WebElement link = d.findElement(By.cssSelector("a[href=\"/intl/en/ads/\"]"));
link.click();
assertTrue(d.getTitle().contains("Ads"));
}
Aggregations