List of usage examples for org.openqa.selenium.remote DesiredCapabilities DesiredCapabilities
public DesiredCapabilities(String browser, String version, Platform platform)
From source file:com.github.licanhua.test.framework.config.AbstractConfiguration.java
License:Apache License
public DesiredCapabilities getDesiredCapabilities(String browserName) { String path = Const.BROWSER_CONFIG_DIR + browserName + ".properties"; Properties properties = ConfigurationHelper.load(path); String version = getString(Const.BROWSER_VERSION, Const.DEFAULT_BROWSER_VERSION); String platform = getString(Const.BROWSER_PLATFORM, Const.DEFAULT_BROWSER_PLATFORM); DesiredCapabilities caps = new DesiredCapabilities(browserName, version, Platform.fromString(platform)); for (Object key : properties.keySet()) { caps.setCapability((String) key, properties.get(key)); }//from w w w . ja va 2s .c o m return caps; }
From source file:com.github.trask.sandbox.saucelabs.SauceLabsWebDriverProvider.java
License:Apache License
public WebDriver get(String testName) { logger.debug("get()"); DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "3.6.", Platform.WINDOWS); capabilities.setCapability("name", testName); URL url;/*from ww w .j a v a2s.com*/ try { url = new URL("http://" + sauceLabsCredentials.getUsername() + ":" + sauceLabsCredentials.getApiKey() + "@ondemand.saucelabs.com/wd/hub"); } catch (MalformedURLException e) { throw new IllegalStateException(e); } return new RemoteWebDriver(url, capabilities); }
From source file:com.google.android.testing.nativedriver.common.AndroidCapabilities.java
License:Apache License
/** * Returns a {@code DesiredCapabilities} object that matches the AND. Users * of AND generally do not need to call this method directly. *//*from w w w.j a v a2s . co m*/ public static DesiredCapabilities get() { return new DesiredCapabilities("android native", "2.2", Platform.ANDROID); }
From source file:com.googlecode.ounit.selenium.WebDriverFactory.java
License:Open Source License
public static WebDriver newInstance(Browser b) { switch (b) {//from w ww . j a v a2s. c om case FIREFOX: return new FirefoxDriver(); case CHROME: return new ChromeDriver(); case IE: return new InternetExplorerDriver(); case HTMLUNIT: /* * Make sure we have a fully capable HtmlUnitDriver and * silence the stupid warnings about text/javascript */ HtmlUnitDriver rv = new HtmlUnitDriver(new DesiredCapabilities("htmlunit", "firefox", Platform.ANY)) { @Override protected WebClient modifyWebClient(WebClient client) { final IncorrectnessListener delegate = client.getIncorrectnessListener(); client.setIncorrectnessListener(new IncorrectnessListener() { @Override public void notify(String message, Object origin) { if (message.contains("Obsolete") && message.contains("/javascript")) return; delegate.notify(message, origin); } }); return super.modifyWebClient(client); } }; return rv; default: throw new IllegalArgumentException("Invalid browser specified"); } }
From source file:com.machinepublishers.jbrowserdriver.SeleniumProvider.java
License:Apache License
public SeleniumProvider() { super(new DesiredCapabilities("jbrowserdriver", "1", Platform.ANY), JBrowserDriver.class); }
From source file:com.smash.revolance.ui.materials.mock.webdriver.driver.MockedWebDriver.java
License:Open Source License
public MockedWebDriver(int port) throws MalformedURLException { super(new URL(String.format("http://localhost:%d/hub", port)), new DesiredCapabilities("MockedWebDriver", "", Platform.ANY)); }
From source file:de.iteratec.iteraplan.webtests.poc.SeleniumMultipleBrowserTest.java
License:Open Source License
/** * This method reads the browser configuration out of the system properties. * System property for browser = browserEnvironment * Multiple browsers are separated by a "," (no spaces). * If no browser configuration exists, Firefox is chosen as default browser. * Throws {@link NullPointerException} if the browserEnvironment is not set * @return A list of browsers to test against *//* www. j a v a 2s . co m*/ @Parameters(name = "{1}") public static List<Object[]> browserConfiguration() { List<Object[]> browsers = new ArrayList<Object[]>(); String capabilities = System.getProperty(BROWSER_PROPERTY_NAME); if (capabilities != null) { StringTokenizer browserTokenizer = new StringTokenizer(capabilities, BROWSER_DELIMITER); while (browserTokenizer.hasMoreTokens()) { StringTokenizer versionTokenizer = new StringTokenizer(browserTokenizer.nextToken(), VERSION_DELIMITER); String browser = versionTokenizer.nextToken(); String version = versionTokenizer.hasMoreTokens() ? versionTokenizer.nextToken() : ""; browsers.add(new Object[] { new DesiredCapabilities(browser, version, Platform.ANY), browser + version }); } } if (browsers.size() == 0) { //If no environment was found use firefox as default. browsers.add(new Object[] { DesiredCapabilities.firefox(), "firefox" }); } return browsers; }
From source file:endtoend.browser.driver.builders.EdgeDriverBuilderTest.java
License:Apache License
@Test(expected = VerySpecialExceptionOnlyWeThrow.class) @SuppressWarnings("deprecation") public void withCapabilities() { // given/*from w w w.j av a 2s .c om*/ DesiredCapabilities capabilities = new DesiredCapabilities("MicrosoftEdge", "", Platform.WINDOWS) { @Override public boolean is(String capabilityName) { throw new VerySpecialExceptionOnlyWeThrow(); } }; // when $.driver().useEdge().autoDriverDownload().withCapabilities(capabilities); DriverBuilderTestUtil.openAnyUrl(); // then // exception is thrown when the browser inits with the passed capabilities }
From source file:endtoend.browser.driver.builders.OperaDriverBuilderTest.java
License:Apache License
@Test(expected = DriverBuilderTestUtil.VerySpecialExceptionOnlyWeThrow.class) @SuppressWarnings("deprecation") public void withCapabilities() { // given/*from w w w . ja v a2s . c o m*/ DesiredCapabilities operaBlink = DesiredCapabilities.operaBlink(); DesiredCapabilities capabilities = new DesiredCapabilities(operaBlink.getBrowserName(), operaBlink.getVersion(), operaBlink.getPlatform()) { @Override public boolean is(String capabilityName) { throw new DriverBuilderTestUtil.VerySpecialExceptionOnlyWeThrow(); } }; // when $.driver().useOpera().autoDriverDownload().withCapabilities(capabilities); DriverBuilderTestUtil.openAnyUrl(); // then // exception is thrown when the browser inits with the passed capabilities }
From source file:minium.web.config.WebDriverConfigurationTest.java
License:Apache License
@Test public void testWebElementsDriverProperties() throws MalformedURLException { DesiredCapabilities expectedDesiredCapabilities = new DesiredCapabilities(BrowserType.CHROME, "39.0", Platform.LINUX);//from w w w . j a v a2 s . c om DesiredCapabilities expectedRequiredCapabilities = new DesiredCapabilities( ImmutableMap.of(CapabilityType.PLATFORM, Platform.LINUX.name())); assertThat(new DesiredCapabilities(webDriverProperties.getDesiredCapabilities()), equalTo(expectedDesiredCapabilities)); assertThat(new DesiredCapabilities(webDriverProperties.getRequiredCapabilities()), equalTo(expectedRequiredCapabilities)); assertThat(webDriverProperties.getUrl(), equalTo(new URL("http://localhost:4444/wd/hub"))); assertThat(webDriverProperties.getWindow().getSize(), equalTo(new DimensionProperties(1280, 1024))); assertThat(webDriverProperties.getWindow().getPosition(), nullValue()); }