use of org.openqa.selenium.chrome.ChromeOptions in project archiva by apache.
the class WebdriverUtility method newWebDriver.
public static WebDriver newWebDriver(String seleniumBrowser, String seleniumHost, int seleniumPort, boolean seleniumRemote) {
log.info("WebDriver {}, {}, {}, {}", seleniumBrowser, seleniumHost, seleniumPort, seleniumRemote);
if (seleniumRemote && StringUtils.isEmpty(seleniumHost)) {
throw new IllegalArgumentException("seleniumHost must be set, when seleniumRemote=true");
}
try {
if (StringUtils.contains(seleniumBrowser, "chrome")) {
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
if (seleniumRemote) {
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities);
} else {
return new ChromeDriver(options);
}
}
if (StringUtils.contains(seleniumBrowser, "safari")) {
if (seleniumRemote) {
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.safari());
} else {
return new SafariDriver();
}
}
if (StringUtils.contains(seleniumBrowser, "iexplore")) {
if (seleniumRemote) {
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.internetExplorer());
} else {
new InternetExplorerDriver();
}
}
if (StringUtils.contains(seleniumBrowser, "firefox")) {
if (seleniumRemote) {
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.firefox());
} else {
return new FirefoxDriver();
}
}
DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
capabilities.setJavascriptEnabled(true);
capabilities.setVersion("firefox-52");
WebDriver driver;
if (seleniumRemote) {
driver = new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities);
} else {
driver = new HtmlUnitDriver(capabilities) {
@Override
protected WebClient modifyWebClient(WebClient client) {
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
client.getOptions().setThrowExceptionOnScriptError(false);
client.getOptions().setCssEnabled(true);
return client;
}
};
}
return driver;
} catch (MalformedURLException e) {
throw new RuntimeException("Initializion of remote driver failed");
}
}
use of org.openqa.selenium.chrome.ChromeOptions in project Bytecoder by mirkosertic.
the class BytecoderUnitTestRunner method newDriverForTest.
private WebDriver newDriverForTest() {
ChromeOptions theOptions = new ChromeOptions();
theOptions.addArguments("headless");
theOptions.addArguments("disable-gpu");
LoggingPreferences theLoggingPreferences = new LoggingPreferences();
theLoggingPreferences.enable(LogType.BROWSER, Level.ALL);
theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);
DesiredCapabilities theCapabilities = DesiredCapabilities.chrome();
theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions);
return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities);
}
use of org.openqa.selenium.chrome.ChromeOptions in project jmeter-plugins by undera.
the class ChromeDriverConfigTest method shouldHaveAndroidConfigWhenAndroidIsEnabled.
@Test
public void shouldHaveAndroidConfigWhenAndroidIsEnabled() {
config.setAndroidEnabled(true);
final Capabilities capabilities = config.createCapabilities();
ChromeOptions options = (ChromeOptions) capabilities.getCapability(ChromeOptions.CAPABILITY);
assertThat("ChromeOption expected", options, is(notNullValue()));
final String androidConfig = (String) options.getExperimentalOption("androidPackage");
assertThat(androidConfig, is("com.android.chrome"));
}
use of org.openqa.selenium.chrome.ChromeOptions in project jmeter-plugins by undera.
the class ChromeDriverConfig method createCapabilities.
Capabilities createCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, createProxy());
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
if (isAndroidEnabled() || isHeadlessEnabled()) {
// Map<String, String> chromeOptions = new HashMap<String, String>();
// chromeOptions.put("androidPackage", "com.android.chrome");
ChromeOptions chromeOptions = new ChromeOptions();
if (isAndroidEnabled()) {
chromeOptions.setExperimentalOption("androidPackage", "com.android.chrome");
}
if (isHeadlessEnabled()) {
chromeOptions.addArguments("--headless");
}
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
}
return capabilities;
}
use of org.openqa.selenium.chrome.ChromeOptions 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);
}
Aggregations