Search in sources :

Example 1 with WebDriver

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();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver)

Example 2 with WebDriver

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();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver)

Example 3 with WebDriver

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);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Cookie(org.openqa.selenium.Cookie) Date(java.util.Date) Test(org.junit.Test)

Example 4 with WebDriver

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);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test)

Example 5 with WebDriver

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());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) 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