Java 类org.openqa.selenium.remote.DesiredCapabilities 实例源码

项目:Spring-Security-Third-Edition    文件:SeleniumTestUtilities.java   
public static WebDriver getFirefoxDriver()
            throws Exception
    {
        baseDir = new File(".").getPath();
        System.out.println("******** " + baseDir);

        String path = "src/test/resources/geckodriver";
        System.out.println("******** " + path);
        System.setProperty("webdriver.gecko.driver", path);

        DesiredCapabilities capabilities =  DesiredCapabilities.firefox();
        capabilities.setCapability("marionette", true);
        capabilities.setCapability("networkConnectionEnabled", true);
        capabilities.setCapability("browserConnectionEnabled", true);


        WebDriver driver = new RemoteWebDriver(
                new URL("http://localhost:4444"),
                capabilities);

//      WebDriver driver = new MarionetteDriver(capabilities);

        return driver;
    }
项目:delay-repay-bot    文件:PhantomJSTest.java   
@Test
public void testDriver() throws IOException {
    WebDriver driver = new RemoteWebDriver(toUrl("http://localhost:9515"), DesiredCapabilities.chrome());
    driver.get(URL2);

    String response = driver.getPageSource();
    Document doc = Jsoup.connect(URL2).ignoreContentType(true).get();
    Elements scriptTags = doc.select("body");

    // get All functions


    try {
        String result = (String) engine.eval(response);
    } catch (ScriptException e) {
        e.printStackTrace();
    }

    log.info("PageSource " + response);

    driver.quit();
}
项目:bootstrap    文件:AbstractSequentialSeleniumTest.java   
/**
 * Run a capability.
 */
private void runSequentialIndex(final WebDriver[] drivers, final boolean[] success, final int driverIndex, final DesiredCapabilities capability) {
    AbstractSequentialSeleniumTest seleniumTest = this;
    try {
        final WebDriver driver = getRemoteDriver(capability);
        drivers[driverIndex] = driver;
        seleniumTest = this.getClass().newInstance();
        cloneAndRun(seleniumTest, driver, capability);
        success[driverIndex] = true;
    } catch (final Exception e) {
        log.error("Unable to build the driver for requested capability, other tests are not interrupted : " + capability, e);
    } finally {
        cleanup();
        seleniumTest.cleanup();
    }
}
项目:appium_tutorial    文件:BaseDriver.java   
@Before
  public void setUp() throws Exception {
      File classpathRoot = new File(System.getProperty("user.dir"));
      File appDir = new File(classpathRoot, "/apps/");
      File app = new File(appDir.getCanonicalPath(), "Financius.v0.18.2.apk");
      DesiredCapabilities capabilities = new DesiredCapabilities();
      capabilities.setCapability("deviceName", ""); // device UID from adb
capabilities.setCapability("platformVersion", "6.0.1"); // android version
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.code44.finance"); // package name
capabilities.setCapability("appWaitActivity", "com.code44.finance.*"); // default activity

capabilities.setCapability("no-reset", "true"); 
capabilities.setCapability("full-reset", "false"); 
      driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

  }
项目:marathonv5    文件:JavaDriverTest.java   
public void clickWithNativeEvents() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("nativeEvents", true);
    driver = new JavaDriver(new JavaProfile(), caps, caps);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    WebElement element1 = driver.findElement(By.name("click-me"));
    element1.click();
    AssertJUnit.assertTrue(buttonClicked);
    buttonClicked = false;
    new Actions(driver).click().perform();
    AssertJUnit.assertTrue(buttonClicked);
    AssertJUnit.assertTrue(buttonMouseActions.toString().contains("clicked(1)"));
    buttonMouseActions.setLength(0);
    new Actions(driver).contextClick().perform();
    AssertJUnit.assertTrue(buttonMouseActions.toString(), buttonMouseActions.toString().contains("pressed(3-popup)")
            || buttonMouseActions.toString().contains("released(3-popup)"));
}
项目:Cognizant-Intelligent-Test-Scripter    文件:WebDriverFactory.java   
private static WebDriver createRemoteDriver(String url, DesiredCapabilities caps, Boolean checkForProxy,
        Properties props) {
    try {
        if (isAppiumNative(url, caps.asMap())) {
            if (isAndroidNative(caps.asMap())) {
                return new io.appium.java_client.android.AndroidDriver(new URL(url), caps);
            } else if (isIOSNative(caps.asMap())) {
                return new io.appium.java_client.ios.IOSDriver(new URL(url), caps);
            }
        }
        if (url == null) {
            return new RemoteWebDriver(caps);
        }
        if (checkForProxy) {
            return new RemoteWebDriver(RemoteProxy.getProxyExecutor(new URL(url), props), caps);
        }
        return new RemoteWebDriver(new URL(url), caps);
    } catch (MalformedURLException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }
    return null;
}
项目:marathonv5    文件:DragAndDropTest.java   
public void dndWithCopy() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities();
    // caps.setCapability("nativeEvents", true);
    driver = new JavaDriver(caps, caps);
    WebElement list = driver.findElement(By.cssSelector("list"));
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 4\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
    WebElement listitem1 = driver.findElement(By.cssSelector("list::nth-item(1)"));
    WebElement listitem5 = driver.findElement(By.cssSelector("list::nth-item(5)"));
    listitem1.click();
    driver.clearlogs(LogType.DRIVER);
    Keys copyKey = Keys.ALT;
    if (Platform.isWindows()) {
        copyKey = Keys.CONTROL;
    }
    new Actions(driver).keyDown(copyKey).dragAndDrop(listitem1, listitem5).keyUp(copyKey).perform();
    waitTillDropCompletes(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list);
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
}
项目:bootstrap    文件:AbstractParallelSeleniumTest.java   
/**
 * Prepare the thread instances.
 */
private Thread[] prepareThreads(final WebDriver[] drivers, final boolean[] success) { // NOPMD
    final Thread[] threads = new Thread[repeatedCapabilities.length]; // NOPMD -- thread
    for (int index = 0; index < repeatedCapabilities.length; index++) {
        final int driverIndex = index;
        final DesiredCapabilities capability = repeatedCapabilities[driverIndex];
        success[driverIndex] = false;
        try {
            final WebDriver driver = getRemoteDriver(capability);
            drivers[driverIndex] = driver;
            threads[driverIndex] = prepareThread(driver, driverIndex, success, capability);
        } catch (final Exception e) {
            log.error("Unable to connect the remote web driver, other tests are not interrupted : " + capability, e);
        } finally {
            cleanup();
        }
    }
    return threads;
}
项目:NoraUi    文件:DriverFactory.java   
/**
 * Sets the target browser binary path in chromeOptions if it exists in configuration.
 *
 * @param capabilities
 *            The global DesiredCapabilities
 */
private void setChromeOptions(final DesiredCapabilities capabilities, ChromeOptions chromeOptions) {

    // Set custom downloaded file path. When you check content of downloaded file by robot.
    HashMap<String, Object> chromePrefs = new HashMap<>();
    chromePrefs.put("download.default_directory", System.getProperty("user.dir") + File.separator + "downloadFiles");
    chromeOptions.setExperimentalOption("prefs", chromePrefs);

    // Set custom chromium (if you not use default chromium on your target device)
    String targetBrowserBinaryPath = Context.getWebdriversProperties("targetBrowserBinaryPath");
    if (targetBrowserBinaryPath != null && !"".equals(targetBrowserBinaryPath)) {
        chromeOptions.setBinary(targetBrowserBinaryPath);
    }

    capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
}
项目:NoraUi    文件:DriverFactory.java   
/**
 * Generates a htmlunit webdriver.
 *
 * @return
 *         A htmlunit webdriver
 */
private WebDriver generateHtmlUnitDriver() {
    logger.info("Generating HtmlUnit driver...");
    final DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    capabilities.setJavascriptEnabled(true);

    setLoggingLevel(capabilities);

    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }
    return new HtmlUnitDriver(capabilities);
}
项目:webdriver-junit5-archetype    文件:SuiteConfiguration.java   
public Capabilities getCapabilities() throws IOException {
  String capabilitiesFile = properties.getProperty("capabilities");

  Properties capsProps = new Properties();
  capsProps.load(SuiteConfiguration.class.getResourceAsStream(capabilitiesFile));

  DesiredCapabilities capabilities = new DesiredCapabilities();
  for (String name : capsProps.stringPropertyNames()) {
    String value = capsProps.getProperty(name);
    if (value.toLowerCase().equals("true") || value.toLowerCase().equals("false")) {
      capabilities.setCapability(name, Boolean.valueOf(value));
    } else if (value.startsWith("file:")) {
      capabilities.setCapability(name, new File(".", value.substring(5)).getCanonicalFile().getAbsolutePath());
    } else {
      capabilities.setCapability(name, value);
    }
  }

  return capabilities;
}
项目:WebAndAppUITesting    文件:DriverFactory.java   
/**
 * 启动ios的safari浏览器
 * 
 * @param noReset
 */
private void createIOSSafariDriver(Boolean noReset) {

    capabilities = new DesiredCapabilities();

    capabilities.setCapability("platformName", property.getProperty("platformName"));
    capabilities.setCapability("platformVersion", property.getProperty("platformVersion"));
    capabilities.setCapability("deviceName", property.getProperty("deviceName"));
    capabilities.setCapability("browserName", property.getProperty("browserName", "Safari"));
    capabilities.setCapability("autoAcceptAlerts", property.getProperty("autoAcceptAlerts", "True"));
    // debug时,等待时间调大点!!
    capabilities.setCapability("newCommandTimeout", property.getProperty("newCommandTimeout"));
    capabilities.setCapability("noReset", noReset); // 不卸载、不重装
    capabilities.setCapability("noSign", "true");
    // 重置输入法,并且设置可以中文输入
    capabilities.setCapability("unicodeKeyboard", "True");
    capabilities.setCapability("resetKeyboard", "True");

    try {
        driver = new IOSDriver<MobileElement>(new URL(property.getProperty("remote.address")), capabilities);
    } catch (Exception e) {
        e.printStackTrace();
        AssertUtil.fail("初始化对象失败,e = " + e.getMessage());
    }
}
项目:SilkAppDriver    文件:MultiWindowTests.java   
@Before
public void startApp() throws Exception {
    DesiredCapabilities capabilities = new DesiredCapabilities();

    Map<String, Object> baseState = new HashMap<>();
    baseState.put("type", "NATIVE");
    baseState.put("executable", APP);
    baseState.put("locator", "//Window");

    capabilities.setCapability("appdriver-basestate", baseState);

    Map<String, Object> options = new HashMap<>();
    options.put("closeOnQuit", true);

    capabilities.setCapability("appdriver-options", options);

    driver = new RemoteWebDriver(new URL("http://localhost:8080"), capabilities);
}
项目:devtools-driver    文件:NewSessionHandler.java   
private ServerSideSession safeStart(DesiredCapabilities cap) {
  ServerSideSession session = null;
  try {
    // init session
    session = getServer().createSession(cap);
    if (session == null) {
      throw new SessionNotCreatedException(
          "The server is currently shutting down and doesn't accept new tests.");
    }

    // start session
    session.start();
    return session;
  } catch (Exception e) {
    // TODO(user): Clean this up to meet logging best practices (should not log and throw).
    logger.atSevere().withCause(e).log("Error starting the session");
    if (session != null) {
      session.stop();
    }
    throw new SessionNotCreatedException(e.getMessage(), e);
  }
}
项目:devtools-driver    文件:GetSessionsHandler.java   
@Override
public Response handle() throws Exception {
  JSONArray res = new JSONArray();
  for (ServerSideSession s : getServer().getSessions()) {
    JSONObject session = new JSONObject();
    session.put("id", s.getSessionId());
    session.put("capabilities", new DesiredCapabilities());
    res.put(session);
  }

  Response resp = new Response();
  resp.setSessionId("dummy one");
  resp.setStatus(0);
  resp.setValue(res.toString());
  return resp;
}
项目:selenide-appium    文件:AndroidDriverProvider.java   
@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
  Configuration.startMaximized = false;
  Configuration.captureJavascriptErrors = false;

  capabilities.setCapability(MobileCapabilityType.VERSION, "4.4.2");
  capabilities.setCapability("automationName", "Appium");
  capabilities.setCapability("platformName", "Android");
  capabilities.setCapability("deviceName", "0123456789ABCDEF");
  capabilities.setCapability(APP_PACKAGE, "com.android.calculator2");
  capabilities.setCapability(APP_ACTIVITY, "com.android.calculator2.Calculator");

  try {
    return new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
  } catch (MalformedURLException e) {
    throw new RuntimeException(e);
  }
}
项目:selenium-camp-17    文件:Java7WebDriverFactory.java   
public static WebDriver getDriverUsingIf(DesiredCapabilities desiredCapabilities) {
    if (desiredCapabilities == null) {
        throw new IllegalStateException("DesiredCapabilities are missing!");
    }

    final String browser = desiredCapabilities.getBrowserName();

    if (CHROME.equalsIgnoreCase(browser)) {
        return new ChromeDriver(desiredCapabilities);
    } else if (FIREFOX.equalsIgnoreCase(browser)) {
        return new FirefoxDriver(desiredCapabilities);
    } else if (browser.isEmpty()) {
        throw new IllegalStateException("'browser' capability is missing!");
    }

    throw new IllegalArgumentException(desiredCapabilities.getBrowserName() + " browser is not supported!");
}
项目:akita-testing-template    文件:AkitaChromeDriverProvider.java   
@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
    Map<String, Object> preferences = new Hashtable<>();
    preferences.put("profile.default_content_settings.popups", 0);
    preferences.put("download.prompt_for_download", "false");
    String downloadsPath = System.getProperty("user.home") + "/Downloads";
    preferences.put("download.default_directory", loadSystemPropertyOrDefault("fileDownloadPath", downloadsPath));
    preferences.put("plugins.plugins_disabled", new String[]{
            "Adobe Flash Player", "Chrome PDF Viewer"});
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", preferences);

    capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    return new ChromeDriver(capabilities);
}
项目:colibri-ui    文件:AbsDriverConfigurator.java   
protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
    capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
    String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
    capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
    capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
    return capabilities;
}
项目:bootstrap    文件:AbstractSequentialSeleniumTest.java   
/**
 * Sequentially run the desired capabilities.
 */
protected void runSequential() { // NOPMD -- thread
    final WebDriver[] drivers = new WebDriver[repeatedCapabilities.length];
    final boolean[] success = new boolean[repeatedCapabilities.length];
    for (int index = 0; index < repeatedCapabilities.length; index++) {
        final int driverIndex = index;
        final DesiredCapabilities capability = repeatedCapabilities[driverIndex];
        success[driverIndex] = false;
        runSequentialIndex(drivers, success, driverIndex, capability);
    }

    final List<String> faillures = checkResults(success);
    Assert.assertTrue("All browsers test failed", faillures.size() != success.length);
    Assert.assertEquals("Some browsers test failed", 0, faillures.size());
}
项目:colibri-ui    文件:BaseIOSDriverConfigurator.java   
@Override
public AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings) {
    DesiredCapabilities capabilities = createCapabilities(driversSettings);
    additionalCapabilities(driversSettings, capabilities);
    IOSDriver iosDriver = new IOSDriver(getRemoteAddress(driversSettings.getAppiumRemoteUrl()), capabilities);
    iosDriver.manage().timeouts().implicitlyWait(driversSettings.getImplicitlyWaitInSeconds(), TimeUnit.SECONDS);
    return iosDriver;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:IOSpy.java   
private static void startIOSSpy() {
    try {
        if (wd == null) {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            for (String key : caps.keySet()) {
                capabilities.setCapability(key, caps.get(key));
            }
            wd = new IOSDriver(new URL(url), capabilities);
        }
    } catch (Exception ex) {
        Logger.getLogger(IOSpy.class.getName()).log(Level.SEVERE, null, ex);
        Notification.show("Couldn't Connect to Device/Simulator Check Settings/Appium Logs");
    }
}
项目:jspider    文件:WebDriverFactory.java   
public WebDriverEx createWebDriver(DriverService driverService,
                                      DesiredCapabilities desiredCapabilities,
                                      SiteConfig siteConfig,
                                      DriverConfig driverConfig) throws IOException {
    driverService.start();

    //自定义HttpClientFactory用于设置命令超时时间
    ApacheHttpClient.Factory httpClientFactory = createHttpClientFactory(siteConfig, driverConfig);
    HttpCommandExecutor httpCommandExecutor = new HttpCommandExecutor(
            ImmutableMap.<String, CommandInfo>of(), driverService.getUrl(), httpClientFactory);
    WebDriverEx webDriver = new WebDriverEx(httpCommandExecutor, desiredCapabilities);
    webDriver.setDriverService(driverService);
    webDriver.setCreatedTime(new Date());

    webDriver.manage().timeouts().implicitlyWait(driverConfig.getImplicitlyWait(), TimeUnit.MILLISECONDS);
    webDriver.manage().timeouts().pageLoadTimeout(driverConfig.getPageLoadTimeout(), TimeUnit.MILLISECONDS);
    webDriver.manage().timeouts().setScriptTimeout(driverConfig.getScriptTimeout(), TimeUnit.MILLISECONDS);

    return webDriver;
}
项目:jspider    文件:WebDriverFactory.java   
public DesiredCapabilities createChromeDesiredCapabilities(SiteConfig siteConfig, DriverConfig driverConfig) {
    ChromeDesiredCapabilities capabilities = ChromeDesiredCapabilities.create();

    capabilities.setImagesEnabled(false);
    capabilities.setFlashEnabled(false);
    capabilities.setAutomaticDownloadsEnabled(false);
    capabilities.setJavascriptEnabled(true);

    return capabilities;
}
项目:mobileAutomation    文件:Driver.java   
/**
 * Get an instance of an WebDriver.
 * 
 * @param appiumServerUrl - servers URL
 * @param platformName - OS name (Android, IOS ...)
 * @param deviceName - device model name
 * @param app - mobile application to install/run
 * @return - an android driver connected via Appium
 */
public static AndroidDriver<?> driverStart(String appiumServerUrl, 
        String platformName,
        String deviceName,
        String app){



    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platformName", platformName);
    capabilities.setCapability("deviceName", deviceName);
    capabilities.setCapability("app", app);



    try {
        driver = new AndroidDriver<>(new URL(appiumServerUrl), capabilities);
    } catch (MalformedURLException e) {
        throw new TestCaseFailure("Could not start remote driver! ", e);
    }

    logger.log("WebDriver: " + driver.getClass().getCanonicalName());
    setDefaultImplicitWait();
    logger.log("implicit wait: " + defaultWait + "s");

    return driver;
}
项目:phoenix.webui.framework    文件:CapabilityConfig.java   
/**
 * @param engineCapMap 用于保存浏览器配置的返回结果
 * @param enginePro 引擎配置集合
 */
public CapabilityConfig(Map<String, DesiredCapabilities> engineCapMap,
        Properties enginePro)
{
    this.engineCapMap = engineCapMap;
    this.enginePro = enginePro;
}
项目:phoenix.webui.framework    文件:CapabilityConfig.java   
/**
 * 火狐浏览器配置
 */
private void firefox()
{
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    capability.setCapability("marionette", true);
    engineCapMap.put(DRIVER_FIREFOX, capability);
}
项目:msa-cucumber-appium    文件:MobileApp.java   
private static ThreadLocal<WebDriver> getAndroidDriverThreadLocal(DesiredCapabilities... params) throws IOException {
        final Properties prop = new Properties();
        FileInputStream input = new FileInputStream("src/main/resources/config.properties");
        prop.load(input);

        System.out.println(prop.getProperty("appPath"));
        System.out.println(prop.getProperty("application"));
        System.out.println(prop.getProperty("device"));
        System.out.println(prop.getProperty("platform"));
        System.out.println(prop.getProperty("appiumServer"));

        System.out.println("********************InIt initiated ************");
        File appDir = new File(prop.getProperty("appPath"));
        File app = new File(appDir, prop.getProperty("application"));

        //mandatory capabilities
        capabilities.setCapability("deviceName", prop.getProperty("device"));
//        capabilities.setCapability("deviceName", "ba99f4b7");
        capabilities.setCapability("platformName", prop.getProperty("platform"));
        capabilities.setCapability("app", app.getAbsolutePath());
        //capabilities.setCapability("noReset",false);

        return new ThreadLocal<WebDriver>() {
            @Override
            protected WebDriver initialValue() {
                AndroidDriver<WebElement> androidDriver = null;
                try {
                    androidDriver = new AndroidDriver<WebElement>(new URL(prop.getProperty("appiumServer")), capabilities);
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                }
                return androidDriver;
            }
        };
    }
项目:marathonv5    文件:JavaDriver.java   
private static Capabilities dropCapabilities(Capabilities capabilities, String... keysToRemove) {
    if (capabilities == null) {
        return new DesiredCapabilities();
    }
    final Set<String> toRemove = Sets.newHashSet(keysToRemove);
    DesiredCapabilities caps = new DesiredCapabilities(Maps.filterKeys(capabilities.asMap(), new Predicate<String>() {
        @Override public boolean apply(String key) {
            return !toRemove.contains(key);
        }
    }));

    return caps;
}
项目:marathonv5    文件:JavaDriverLogsTest.java   
public void loggingWorks() {
    LoggingPreferences prefs = new LoggingPreferences();
    prefs.enable(LogType.DRIVER, Level.INFO);
    DesiredCapabilities caps = JavaDriver.defaultCapabilities();
    caps.setCapability(CapabilityType.LOGGING_PREFS, prefs);
    driver = new JavaDriver(caps, caps);
    LogEntries logEntries = driver.manage().logs().get(LogType.DRIVER);
    List<LogEntry> all = logEntries.getAll();
    AssertJUnit.assertEquals(2, all.size());
    AssertJUnit.assertTrue(all.get(0).getMessage().contains("A new session created. sessionID = "));
}
项目:SWET    文件:BrowserDriver.java   
private static DesiredCapabilities capabilitiesSafari() {
    DesiredCapabilities capabilities = DesiredCapabilities.safari();
    SafariOptions options = new SafariOptions();
    options.setUseCleanSession(true);
    capabilities.setCapability(SafariOptions.CAPABILITY, options);
    return capabilities;
}
项目:opentest    文件:AppiumHelper.java   
/**
 * Inject desired capabilities from configuration into the specified
 * DesiredCapabilities object.
 */
private static void injectCapsFromConfig(DesiredCapabilities caps) {
    Object capsFromConfig = config.get("appium.desiredCapabilities", null);

    if (capsFromConfig instanceof Map) {
        Map<String, Object> capsFromConfigMap = (Map) capsFromConfig;
        for (Map.Entry entry : capsFromConfigMap.entrySet()) {
            if (entry.getValue() != null) {
                caps.setCapability(entry.getKey().toString(), entry.getValue());
            }
        }
    }
}
项目:bootstrap    文件:TAbstractSeleniumITCase.java   
/**
 * Create the driver instance
 */
@Override
protected void prepareDriver() throws Exception {
    if (!isLocalTest()) {
        capability = DesiredCapabilities.phantomjs();
    }
    super.prepareDriver();
}
项目:marathonv5    文件:JavaDriverTest.java   
public void succeedsWhenRequestingNativeEventsCapability() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", Platform.getCurrent());
    caps.setCapability("nativeEvents", true);
    driver = new JavaDriver(caps, caps);
    Capabilities capabilities = ((RemoteWebDriver) driver).getCapabilities();
    AssertJUnit.assertTrue(capabilities.is("nativeEvents"));
}
项目:Actitime-Framework    文件:DriverFactory.java   
protected void ieDriver() {
    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
    capabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
    capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
    capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
    capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
    capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    System.setProperty("webdriver.ie.driver","./src/main/resources/iedriver/IEDriverServer.exe");
    driver = new InternetExplorerDriver(capabilities);
    driver.manage().window().maximize();
}
项目:marathonv5    文件:LaunchJavaCommandLineTest.java   
@BeforeMethod public void createDriver() {
    System.setProperty(Constants.PROP_PROJECT_FRAMEWORK, Constants.FRAMEWORK_SWING);
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE);
    File f = findFile();
    profile.addClassPath(f);
    profile.setRecordingPort(startRecordingServer());
    profile.setMainClass("com.sun.swingset3.SwingSet3");
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}
项目:marathonv5    文件:LaunchCommandLineTest.java   
@BeforeClass public void createDriver() {
    System.setProperty(Constants.PROP_PROJECT_FRAMEWORK, Constants.FRAMEWORK_SWING);
    JavaProfile profile = new JavaProfile(LaunchMode.COMMAND_LINE);
    File f = findFile();
    profile.setCommand(f.getAbsolutePath());
    profile.setRecordingPort(startRecordingServer());
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}
项目:functional-programming-selenium-examples    文件:Chrome.java   
@Override
public WebDriver getWebDriver()
{
    System.setProperty("webdriver.chrome.driver", "src/test/resources/chromedriver.2.27");
       DesiredCapabilities capabilities = DesiredCapabilities.chrome();
       return new ChromeDriver(capabilities);
}
项目:functional-programming-selenium-examples    文件:Firefox.java   
@Override
public WebDriver getWebDriver()
{
    System.setProperty("webdriver.gecko.driver", "src/test/resources/geckodriver.v0.11.1.mac");
    DesiredCapabilities capabilities=DesiredCapabilities.firefox();
    WebDriver driver = new FirefoxDriver(capabilities);
       return driver;
}
项目:Spring-Security-Third-Edition    文件:SeleniumTestUtilities.java   
public static WebDriver getFirefoxDriver(String pathToFirefoxExecutable)
{
       String path = "src/test/resources/geckodriver";
    System.setProperty("webdriver.gecko.driver", path);
    System.setProperty("webdriver.firefox.bin", pathToFirefoxExecutable);

    DesiredCapabilities capabilities =  DesiredCapabilities.firefox();
       capabilities.setCapability("marionette", true);
       capabilities.setCapability("networkConnectionEnabled", true);
       capabilities.setCapability("browserConnectionEnabled", true);

    WebDriver driver = new MarionetteDriver(capabilities);

    return driver;
}