use of org.openqa.selenium.WebDriver in project cucumber-jvm by cucumber.
the class RentACarSupport method getAvailableNumberOfCars.
public int getAvailableNumberOfCars() {
WebDriver driver = new HtmlUnitDriver();
try {
driver.get("http://localhost:9878/rentit/available");
WebElement availableCars = driver.findElement(By.id("availableCars"));
String availableCarsString = availableCars.getText();
return Integer.parseInt(availableCarsString);
} finally {
driver.close();
}
}
use of org.openqa.selenium.WebDriver in project cucumber-jvm by cucumber.
the class RentACarSupport method rentACar.
public void rentACar() {
WebDriver driver = new HtmlUnitDriver();
try {
driver.get("http://localhost:9878/rentit/rent");
WebElement rentButton = driver.findElement(By.id("rentButton"));
rentButton.click();
} finally {
driver.close();
}
}
use of org.openqa.selenium.WebDriver in project ghostdriver by detro.
the class CookieTest method shouldAllowToSetCookieThatIsAlreadyExpired.
@Test
public void shouldAllowToSetCookieThatIsAlreadyExpired() {
WebDriver d = getDriver();
d.get("https://github.com/");
// Clear all cookies
assertTrue(d.manage().getCookies().size() > 0);
d.manage().deleteAllCookies();
assertEquals(d.manage().getCookies().size(), 0);
// Added cookie that expires in the past
Cookie addedCookie = new Cookie.Builder("expired", "yes").expiresOn(//< now - 1 second
new Date(System.currentTimeMillis() - 1000)).build();
d.manage().addCookie(addedCookie);
Cookie cookie = d.manage().getCookieNamed("expired");
assertNull(cookie);
}
use of org.openqa.selenium.WebDriver in project ghostdriver by detro.
the class CookieTest method shouldAllowToDeleteCookiesEvenIfNotSet.
@Test
public void shouldAllowToDeleteCookiesEvenIfNotSet() {
WebDriver d = getDriver();
d.get("https://github.com/");
// Clear all cookies
assertTrue(d.manage().getCookies().size() > 0);
d.manage().deleteAllCookies();
assertEquals(d.manage().getCookies().size(), 0);
// All cookies deleted, call deleteAllCookies again. Should be a no-op.
d.manage().deleteAllCookies();
d.manage().deleteCookieNamed("non_existing_cookie");
assertEquals(d.manage().getCookies().size(), 0);
}
use of org.openqa.selenium.WebDriver in project ghostdriver by detro.
the class WindowHandlesTest method enumerateWindowHandle.
@Test
public void enumerateWindowHandle() {
WebDriver d = getDriver();
// Didn't open any page yet: no Window Handles yet
String whandle = d.getWindowHandle();
assertFalse(whandle.isEmpty());
}
Aggregations