Search in sources :

Example 96 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.

the class WebRtcChromeTest method setupTest.

@Before
public void setupTest() {
    ChromeOptions options = new ChromeOptions();
    // This flag avoids to grant the user media
    options.addArguments("--use-fake-ui-for-media-stream");
    // This flag fakes user media with synthetic video (green with spinner
    // and timer)
    options.addArguments("--use-fake-device-for-media-stream");
    driver = new ChromeDriver(options);
}
Also used : ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) Before(org.junit.Before)

Example 97 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver 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 98 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project software-quality by Mur3ph.

the class BrowserDriver method instantiateChromeBrowserDriver.

private void instantiateChromeBrowserDriver() {
    LOGGER.info("++instantiateChromeBrowserDriver()");
    driver = new ChromeDriver();
}
Also used : ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 99 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project muikku by otavanopisto.

the class AbstractUITest method createChromeHeadlessDriver.

protected WebDriver createChromeHeadlessDriver() {
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.addArguments("--headless");
    chromeOptions.addArguments("--disable-gpu");
    WebDriver driver = new ChromeDriver(chromeOptions);
    if (getBrowserDimensions() != null) {
        driver.manage().window().setSize(new Dimension(toIntExact(getBrowserDimensions().get("width")), toIntExact(getBrowserDimensions().get("height"))));
    } else {
        driver.manage().window().setSize(new Dimension(1280, 1024));
    }
    return driver;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) Dimension(org.openqa.selenium.Dimension) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 100 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project muikku by otavanopisto.

the class AbstractUITest method createChromeDriver.

protected RemoteWebDriver createChromeDriver() {
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--lang=en_US");
    options.addArguments("--start-maximized");
    ChromeDriver chromeDriver = new ChromeDriver(options);
    return chromeDriver;
}
Also used : ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Aggregations

ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)609 WebDriver (org.openqa.selenium.WebDriver)245 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)177 WebElement (org.openqa.selenium.WebElement)139 Before (org.junit.Before)75 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)71 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)69 File (java.io.File)68 HashMap (java.util.HashMap)53 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)45 Actions (org.openqa.selenium.interactions.Actions)39 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)36 URL (java.net.URL)32 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)25 BeforeTest (org.testng.annotations.BeforeTest)23 ChromeDriverService (org.openqa.selenium.chrome.ChromeDriverService)21 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)20 FirefoxOptions (org.openqa.selenium.firefox.FirefoxOptions)20 BeforeMethod (org.testng.annotations.BeforeMethod)20 EdgeDriver (org.openqa.selenium.edge.EdgeDriver)19