Search in sources :

Example 26 with WebDriver

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

the class ElementMethodsTest method checkDisplayedOnGoogleSearchBox.

@Test
public void checkDisplayedOnGoogleSearchBox() {
    WebDriver d = getDriver();
    d.get("http://www.google.com");
    WebElement el = d.findElement(By.cssSelector("input[name*='q']"));
    assertTrue(el.isDisplayed());
    el = d.findElement(By.cssSelector("input[type='hidden']"));
    assertFalse(el.isDisplayed());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 27 with WebDriver

use of org.openqa.selenium.WebDriver in project webmagic by code4craft.

the class SeleniumTest method testSelenium.

@Ignore("need chrome driver")
@Test
public void testSelenium() {
    System.getProperties().setProperty("webdriver.chrome.driver", "/Users/yihua/Downloads/chromedriver");
    Map<String, Object> contentSettings = new HashMap<String, Object>();
    contentSettings.put("images", 2);
    Map<String, Object> preferences = new HashMap<String, Object>();
    preferences.put("profile.default_content_settings", contentSettings);
    DesiredCapabilities caps = DesiredCapabilities.chrome();
    caps.setCapability("chrome.prefs", preferences);
    caps.setCapability("chrome.switches", Arrays.asList("--user-data-dir=/Users/yihua/temp/chrome"));
    WebDriver webDriver = new ChromeDriver(caps);
    webDriver.get("http://huaban.com/");
    WebElement webElement = webDriver.findElement(By.xpath("/html"));
    System.out.println(webElement.getAttribute("outerHTML"));
    webDriver.close();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) WebElement(org.openqa.selenium.WebElement) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 28 with WebDriver

use of org.openqa.selenium.WebDriver in project webmagic by code4craft.

the class WebDriverPoolTest method test.

@Ignore("need chrome driver")
@Test
public void test() {
    System.getProperties().setProperty("webdriver.chrome.driver", chromeDriverPath);
    WebDriverPool webDriverPool = new WebDriverPool(5);
    for (int i = 0; i < 5; i++) {
        try {
            WebDriver webDriver = webDriverPool.get();
            System.out.println(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    webDriverPool.closeAll();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 29 with WebDriver

use of org.openqa.selenium.WebDriver in project head by mifos.

the class SeleniumTest method testSearchMifosOnGoogle.

@Test
public void testSearchMifosOnGoogle() throws Exception {
    WebDriver wd = new FirefoxDriver();
    try {
        wd.get("http://www.google.com");
        WebElement element = wd.findElement(By.name("q"));
        element.sendKeys("Mifos");
        element.submit();
    } finally {
        wd.quit();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 30 with WebDriver

use of org.openqa.selenium.WebDriver in project head by mifos.

the class WorkspaceServerLauncherTest method testLogin.

@Test
public void testLogin() throws Exception {
    WebDriver wd = new FirefoxDriver();
    wd.get(getAppURL());
    wd.findElement(By.id(UID)).sendKeys("mifos");
    wd.findElement(By.id(PWD)).sendKeys("testmifos");
    wd.findElement(By.id(BTN)).click();
    Assert.assertTrue(wd.getPageSource().contains("Mifos"));
    Assert.assertTrue(wd.getPageSource().contains("Home"));
    Assert.assertTrue(wd.getPageSource().contains("Search"));
    wd.quit();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) 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