use of org.openqa.selenium.remote.DesiredCapabilities in project activityinfo by bedatadriven.
the class ChromeWebDriverProvider method initPool.
private static WebDriverPool initPool() {
WebDriverPool pool = new WebDriverPool();
// pool.setMaxTotalSize(3);
pool.setCreator(new Function<BrowserProfile, WebDriver>() {
@Override
public WebDriver apply(BrowserProfile input) {
// Start a local http proxy that we can use to control the
// the connection's properties
// ProxyController proxyController = new ProxyController();
// proxyController.start();
Map<String, String> environment = Maps.newHashMap();
if (!Strings.isNullOrEmpty(System.getProperty("browserTimezone"))) {
environment.put("TZ", System.getProperty("browserTimezone"));
}
ChromeDriverService service = new ChromeDriverService.Builder().usingAnyFreePort().usingDriverExecutable(findDriverBin()).withEnvironment(environment).build();
ChromeOptions options = new ChromeOptions();
options.addArguments("--verbose");
//
DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(CapabilityType.PROXY, proxyController.getWebDriverProxy());
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
// return new ProxiedWebDriver(new ChromeDriver(capabilities), proxyController);
return new ChromeDriver(service, capabilities);
}
});
return pool;
}
use of org.openqa.selenium.remote.DesiredCapabilities in project activityinfo by bedatadriven.
the class LocalAppiumProvider method get.
@Override
public AppiumDriver get() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.APP, odkVersion.getApkLocalPath());
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, OdkApp.ODK_COLLECT_PACKAGE);
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, OdkApp.ODK_MAIN_MENU);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "LGOTMS3f380a07");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Selendroid");
return new AndroidDriver(localUrl(), capabilities);
}
use of org.openqa.selenium.remote.DesiredCapabilities in project activityinfo by bedatadriven.
the class PhantomJsInstance method start.
public void start() {
PrintStream errorStream = System.err;
try {
// WebDriver dumps EVERYTHING to stderr
System.setErr(new PrintStream(ByteStreams.nullOutputStream()));
List<String> arguments = Lists.newArrayList();
arguments.add("--webdriver-loglevel=INFO");
if (localStoragePath != null) {
arguments.add("--local-storage-path=" + localStoragePath.getAbsolutePath());
}
Map<String, String> environment = new HashMap<>();
if (homeDir != null) {
environment.put("HOME", homeDir.getAbsolutePath());
}
// proxyController = new ProxyController();
// proxyController.start();
PhantomJSDriverService service = new PhantomJSDriverService.Builder().usingPhantomJSExecutable(resolvePhantomJsPath()).usingAnyFreePort().withLogFile(logFile).withEnvironment(environment).usingCommandLineArguments(arguments.toArray(new String[0])).build();
DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(CapabilityType.PROXY, proxyController.getWebDriverProxy());
webDriver = new PhantomJSDriver(service, capabilities);
webDriver.manage().window().setSize(new Dimension(1400, 1000));
} finally {
System.setErr(errorStream);
}
}
use of org.openqa.selenium.remote.DesiredCapabilities in project activityinfo by bedatadriven.
the class SauceLabsAppiumProvider method get.
@Override
public AppiumDriver get() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", device.getDeviceName());
capabilities.setCapability("platformVersion", device.getPlatformVersion());
capabilities.setCapability("app", getApkUrl(odkVersion));
capabilities.setCapability("appPackage", OdkApp.ODK_COLLECT_PACKAGE);
capabilities.setCapability("appActivity", OdkApp.ODK_PREFERENCES);
capabilities.setCapability("automationName", "Selendroid");
return new AndroidDriver(sauceLabs.getWebDriverServer(), capabilities);
}
use of org.openqa.selenium.remote.DesiredCapabilities in project quick-media by liuyueyi.
the class Html2ImageByJsWrapper method getPhantomJs.
private static PhantomJSDriver getPhantomJs() {
// 设置必要参数
DesiredCapabilities dcaps = new DesiredCapabilities();
// ssl证书支持
dcaps.setCapability("acceptSslCerts", true);
// 截屏支持
dcaps.setCapability("takesScreenshot", true);
// css搜索支持
dcaps.setCapability("cssSelectorsEnabled", true);
// js支持
dcaps.setJavascriptEnabled(true);
// 驱动支持(第二参数表明的是你的phantomjs引擎所在的路径,which/whereis phantomjs可以查看)
// fixme 这里写了执行, 可以考虑判断系统是否有安装,并获取对应的路径 or 开放出来指定路径
dcaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, getPhantomJsPath());
// 创建无界面浏览器对象
return new PhantomJSDriver(dcaps);
}
Aggregations