DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
capabilities.setBrowserName(DesiredCapabilities.firefox()
.getBrowserName());
driver = new RemoteWebDriver(new URL("http://"
+ hostAddress + ":" + hubPort + "/wd/hub"),
capabilities);
} else {
driver = new FirefoxDriver(profile);
}
if (!usePhysicalCam && video != null) {
launchFakeCam();
}
} else if (driverClass.equals(ChromeDriver.class)) {
String chromedriver = null;
if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) {
chromedriver = "chromedriver";
} else if (SystemUtils.IS_OS_WINDOWS) {
chromedriver = "chromedriver.exe";
}
System.setProperty("webdriver.chrome.driver", new File(
"target/webdriver/" + chromedriver).getAbsolutePath());
ChromeOptions options = new ChromeOptions();
// This flag avoids grant the camera
options.addArguments("--use-fake-ui-for-media-stream");
// This flag avoids warning in chrome. See:
// https://code.google.com/p/chromedriver/issues/detail?id=799
options.addArguments("--test-type");
if (!usePhysicalCam) {
// This flag makes using a synthetic video (green with
// spinner) in webrtc. Or it is needed to combine with
// use-file-for-fake-video-capture to use a file faking the
// cam
options.addArguments("--use-fake-device-for-media-stream");
if (video != null) {
options.addArguments("--use-file-for-fake-video-capture="
+ video);
// Alternative: lauch fake cam also in Chrome
// launchFakeCam();
}
}
if (remoteNode != null) {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY,
options);
capabilities.setBrowserName(DesiredCapabilities.chrome()
.getBrowserName());
driver = new RemoteWebDriver(new URL("http://"
+ hostAddress + ":" + hubPort + "/wd/hub"),
capabilities);
} else {
driver = new ChromeDriver(options);