Search in sources :

Example 6 with DesiredCapabilities

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;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriverService(org.openqa.selenium.chrome.ChromeDriverService) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) Map(java.util.Map)

Example 7 with DesiredCapabilities

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);
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) AndroidDriver(io.appium.java_client.android.AndroidDriver)

Example 8 with DesiredCapabilities

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);
    }
}
Also used : PrintStream(java.io.PrintStream) PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Dimension(org.openqa.selenium.Dimension) PhantomJSDriverService(org.openqa.selenium.phantomjs.PhantomJSDriverService)

Example 9 with DesiredCapabilities

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);
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) AndroidDriver(io.appium.java_client.android.AndroidDriver)

Example 10 with DesiredCapabilities

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);
}
Also used : PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities)

Aggregations

DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)178 File (java.io.File)55 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)40 URL (java.net.URL)34 HashMap (java.util.HashMap)34 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)30 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)29 Test (org.testng.annotations.Test)22 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)20 BeforeClass (org.junit.BeforeClass)19 TestSetup (com.coveros.selenified.utilities.TestSetup)17 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)17 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)16 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)14 MalformedURLException (java.net.MalformedURLException)13 Before (org.junit.Before)13 Test (org.junit.Test)13 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)12 Actions (org.openqa.selenium.interactions.Actions)12 Dimension (org.openqa.selenium.Dimension)11