org.openqa.selenium.MutableCapabilities Java Examples
The following examples show how to use
org.openqa.selenium.MutableCapabilities.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebDriverWaitTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void shouldIncludeRemoteInfoForWrappedDriverTimeout() throws IOException { Capabilities caps = new MutableCapabilities(); Response response = new Response(new SessionId("foo")); response.setValue(caps.asMap()); CommandExecutor executor = mock(CommandExecutor.class); when(executor.execute(any(Command.class))).thenReturn(response); RemoteWebDriver driver = new RemoteWebDriver(executor, caps); WebDriver testDriver = mock(WebDriver.class, withSettings().extraInterfaces(WrapsDriver.class)); when(((WrapsDriver) testDriver).getWrappedDriver()).thenReturn(driver); TickingClock clock = new TickingClock(); WebDriverWait wait = new WebDriverWait(testDriver, Duration.ofSeconds(1), Duration.ofMillis(200), clock, clock); assertThatExceptionOfType(TimeoutException.class) .isThrownBy(() -> wait.until(d -> false)) .withMessageContaining("Capabilities {javascriptEnabled: true, platform: ANY, platformName: ANY}") .withMessageContaining("Session ID: foo"); }
Example #2
Source File: FirefoxOptionsTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void canConvertOptionsWithPrefsToCapabilitiesAndRestoreBack() { FirefoxOptions options = new FirefoxOptions( new MutableCapabilities(new FirefoxOptions() .addPreference("string.pref", "some value") .addPreference("int.pref", 42) .addPreference("boolean.pref", true))); Object options2 = options.asMap().get(FirefoxOptions.FIREFOX_OPTIONS); assertThat(options2) .asInstanceOf(InstanceOfAssertFactories.MAP) .extractingByKey("prefs") .asInstanceOf(InstanceOfAssertFactories.MAP) .containsEntry("string.pref", "some value") .containsEntry("int.pref", 42) .containsEntry("boolean.pref", true); }
Example #3
Source File: BrowserStatementTest.java From neodymium-library with MIT License | 6 votes |
private void checkTestEnvironment(BrowserConfiguration config) { Assert.assertNotNull(config); Assert.assertEquals("testEnvironmentFlags", config.getConfigTag()); Assert.assertEquals("Test Environment Browser", config.getName()); MutableCapabilities testCapabilities = config.getCapabilities(); Assert.assertEquals("chrome", testCapabilities.getBrowserName()); Assert.assertEquals(1234, testCapabilities.getCapability("idleTimeout")); Assert.assertEquals(1234, testCapabilities.getCapability("idletimeout")); Assert.assertEquals(5678, testCapabilities.getCapability("maxDuration")); Assert.assertEquals(5678, testCapabilities.getCapability("maxduration")); Assert.assertEquals("3.1234", testCapabilities.getCapability("seleniumVersion")); Assert.assertEquals("3.1234", testCapabilities.getCapability("selenium-version")); Assert.assertEquals("800x600", testCapabilities.getCapability("screenResolution")); Assert.assertEquals("800x600", testCapabilities.getCapability("screen-resolution")); Assert.assertEquals(Platform.VISTA, testCapabilities.getCapability("platform")); Assert.assertEquals("Windows 10", testCapabilities.getCapability("platformName")); Assert.assertEquals("MyDevice", testCapabilities.getCapability("deviceName")); Assert.assertEquals("portrait", testCapabilities.getCapability("deviceOrientation")); Assert.assertEquals("landscape", testCapabilities.getCapability("orientation")); }
Example #4
Source File: SeleniumConfig.java From Selenium-Foundation with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public Path createNodeConfig(String capabilities, URL hubUrl) throws IOException { String nodeConfigPath = getNodeConfigPath().toString(); String configPathBase = nodeConfigPath.substring(0, nodeConfigPath.length() - 5); String hashCode = String.format("%08X", Objects.hash(capabilities, hubUrl)); Path filePath = Paths.get(configPathBase + "-" + hashCode + ".json"); if (filePath.toFile().createNewFile()) { JsonInput input = new Json().newInput(new StringReader(JSON_HEAD + capabilities + JSON_TAIL)); List<MutableCapabilities> capabilitiesList = GridNodeConfiguration.loadFromJSON(input).capabilities; GridNodeConfiguration nodeConfig = GridNodeConfiguration.loadFromJSON(nodeConfigPath); nodeConfig.capabilities = capabilitiesList; nodeConfig.hub = hubUrl.toString(); try (OutputStream out = new BufferedOutputStream(new FileOutputStream(filePath.toFile()))) { out.write(new Json().toJson(nodeConfig).getBytes(StandardCharsets.UTF_8)); } } return filePath; }
Example #5
Source File: DockerDriverHandler.java From selenium-jupiter with Apache License 2.0 | 6 votes |
private DesiredCapabilities getCapabilitiesForAndroid( BrowserInstance browserInstance, String deviceNameCapability) throws IllegalAccessException, IOException { DesiredCapabilities capabilities = browserInstance.getCapabilities(); capabilities.setCapability("browserName", browserName); capabilities.setCapability("deviceName", deviceNameCapability); Optional<Capabilities> optionalCapabilities = annotationsReader != null ? annotationsReader.getCapabilities(parameter, testInstance) : Optional.of(new DesiredCapabilities()); MutableCapabilities options = browserInstance.getDriverHandler() .getOptions(parameter, testInstance); if (optionalCapabilities.isPresent()) { options.merge(optionalCapabilities.get()); } capabilities.setCapability(CAPABILITY, options); log.trace("Using {}", capabilities); return capabilities; }
Example #6
Source File: JsonOutputTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void shouldConvertAProxyCorrectly() { Proxy proxy = new Proxy(); proxy.setHttpProxy("localhost:4444"); MutableCapabilities caps = new DesiredCapabilities("foo", "1", Platform.LINUX); caps.setCapability(CapabilityType.PROXY, proxy); Map<String, ?> asMap = ImmutableMap.of("desiredCapabilities", caps); Command command = new Command(new SessionId("empty"), DriverCommand.NEW_SESSION, asMap); String json = convert(command.getParameters()); JsonObject converted = new JsonParser().parse(json).getAsJsonObject(); JsonObject capsAsMap = converted.get("desiredCapabilities").getAsJsonObject(); assertThat(capsAsMap.get(CapabilityType.PROXY).getAsJsonObject().get("httpProxy").getAsString()) .isEqualTo(proxy.getHttpProxy()); }
Example #7
Source File: InternalSelenseTestBase.java From selenium with Apache License 2.0 | 6 votes |
@Override protected void before() { selenium = INSTANCE; if (selenium != null) { return; } MutableCapabilities caps = new MutableCapabilities(createCapabilities()); caps.setCapability(UNEXPECTED_ALERT_BEHAVIOUR, IGNORE); String baseUrl = whereIs("/common/rc/tests/html/"); WebDriver driver = new WebDriverBuilder().get(caps); selenium = new WebDriverBackedSelenium(driver, baseUrl); selenium.setBrowserLogLevel("debug"); INSTANCE = selenium; }
Example #8
Source File: CustomDriverProvider.java From akita with Apache License 2.0 | 6 votes |
/** * Задает capabilities для запуска Remote драйвера для Selenoid * * @param capabilities - capabilities для установленного браузера * @param remoteUrl - url для запуска тестов, например http://remoteIP:4444/wd/hub * @return WebDriver */ private WebDriver getRemoteDriver(MutableCapabilities capabilities, String remoteUrl) { log.info("---------------run Remote Driver---------------------"); Boolean isSelenoidRun = loadSystemPropertyOrDefault(SELENOID, true); if (isSelenoidRun) { capabilities.setCapability("enableVNC", true); capabilities.setCapability("screenResolution", String.format("%sx%s", loadSystemPropertyOrDefault(WINDOW_WIDTH, DEFAULT_WIDTH), loadSystemPropertyOrDefault(WINDOW_HEIGHT, DEFAULT_HEIGHT))); String sessionName = loadSystemPropertyOrDefault(SELENOID_SESSION_NAME, ""); if (!sessionName.isEmpty()) { capabilities.setCapability("name", String.format("%s %s", sessionName, AkitaScenario.getInstance().getScenario().getName())); } } try { RemoteWebDriver remoteWebDriver = new RemoteWebDriver( URI.create(remoteUrl).toURL(), capabilities ); remoteWebDriver.setFileDetector(new LocalFileDetector()); return remoteWebDriver; } catch (MalformedURLException e) { throw new RuntimeException(e); } }
Example #9
Source File: CloudUtils.java From Quantum with MIT License | 6 votes |
public static MutableCapabilities getDeviceProperties(MutableCapabilities desiredCapabilities) { if (!ConfigurationUtils.isDevice(desiredCapabilities)) return desiredCapabilities; DeviceResult device = null; try { device = getHttpClient().deviceInfo(desiredCapabilities.getCapability("deviceName").toString(), false); } catch (HttpClientException e) { e.printStackTrace(); } for (DeviceParameter parameter : DeviceParameter.values()) { String paramValue = device.getResponseValue(parameter); String capName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, parameter.toString().toLowerCase()); if (!StringUtils.isEmpty(paramValue)) desiredCapabilities.setCapability(capName, paramValue); } return desiredCapabilities; }
Example #10
Source File: BrowserStatementTest.java From neodymium-library with MIT License | 5 votes |
private void checkMultiChrome(BrowserConfiguration config) { Assert.assertNotNull(config); Assert.assertEquals("multiChrome", config.getConfigTag()); Assert.assertEquals("Multi Argument Chrome", config.getName()); MutableCapabilities testCapabilities = config.getCapabilities(); Assert.assertEquals("chrome", testCapabilities.getBrowserName()); LinkedList<String> list = new LinkedList<>(); list.add("-crash-test"); list.add("-window-position=0,0"); list.add("-window-size=1024,768"); Assert.assertEquals(list, config.getArguments()); }
Example #11
Source File: IOSOptionsTest.java From java-client with Apache License 2.0 | 5 votes |
@Test public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); capabilities.setCapability("newCommandTimeout", 60); iosOptions = new IOSOptions(capabilities); assertEquals("Pixel", iosOptions.getDeviceName()); assertEquals("10", iosOptions.getPlatformVersion()); assertEquals(Duration.ofSeconds(60), iosOptions.getNewCommandTimeout()); }
Example #12
Source File: BrowserStatementTest.java From neodymium-library with MIT License | 5 votes |
private void checkFirefox(BrowserConfiguration config) { Assert.assertNotNull(config); Assert.assertEquals("firefox", config.getConfigTag()); Assert.assertEquals("Mozilla Firefox", config.getName()); Assert.assertEquals(null, config.getTestEnvironment()); MutableCapabilities testCapabilities = config.getCapabilities(); Assert.assertEquals("firefox", testCapabilities.getBrowserName()); LinkedList<String> list = new LinkedList<>(); list.add("headless"); Assert.assertEquals(list, config.getArguments()); }
Example #13
Source File: JsonTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void shouldCoerceAListOfCapabilitiesIntoSomethingMutable() { // This is needed since Grid expects each of the capabilities to be mutable List<Capabilities> expected = Arrays.asList( new ImmutableCapabilities("cheese", "brie"), new ImmutableCapabilities("peas", 42L)); Json json = new Json(); String raw = json.toJson(expected); List<Capabilities> seen = json.toType(raw, new TypeToken<List<Capabilities>>(){}.getType()); assertThat(seen).isEqualTo(expected); assertThat(seen.get(0)).isInstanceOf(MutableCapabilities.class); }
Example #14
Source File: BrowserStatementTest.java From neodymium-library with MIT License | 5 votes |
private void checkMultiFirefox(BrowserConfiguration config) { Assert.assertNotNull(config); Assert.assertEquals("multiFirefox", config.getConfigTag()); Assert.assertEquals("Multi Argument Firefox", config.getName()); MutableCapabilities testCapabilities = config.getCapabilities(); Assert.assertEquals("firefox", testCapabilities.getBrowserName()); LinkedList<String> list = new LinkedList<>(); list.add("-headless"); list.add("-width=1024"); list.add("-height=768"); Assert.assertEquals(list, config.getArguments()); }
Example #15
Source File: BaseWebDriverTest.java From demo-java with MIT License | 5 votes |
private void createSauceDriver(MutableCapabilities capabilities, String methodName) { String username = System.getenv("SAUCE_USERNAME"); String accesskey = System.getenv("SAUCE_ACCESS_KEY"); //Create a map of capabilities called "sauce:options", which contain the info necessary to run on Sauce // Labs, using the credentials stored in the environment variables. Also runs using the new W3C standard. MutableCapabilities sauceOptions = new MutableCapabilities(); sauceOptions.setCapability("username", username); sauceOptions.setCapability("accessKey", accesskey); sauceOptions.setCapability("seleniumVersion", "3.141.59"); sauceOptions.setCapability("name", methodName); sauceOptions.setCapability("build", "parallel-TestNG-single-browser-demo"); //Assign the Sauce Options to the base capabilities capabilities.setCapability("sauce:options", sauceOptions); //Create a new RemoteWebDriver, which will initialize the test execution on Sauce Labs servers String SAUCE_REMOTE_URL = "https://ondemand.saucelabs.com/wd/hub"; try { webDriver.set(new RemoteWebDriver(new URL(SAUCE_REMOTE_URL), capabilities)); } catch (MalformedURLException e) { throw new RuntimeException(e); } sessionId.set(((RemoteWebDriver)webDriver.get()).getSessionId().toString()); // set current sessionId String id = ((RemoteWebDriver) getWebDriver()).getSessionId().toString(); sessionId.set(id); }
Example #16
Source File: BaseWebDriverTest.java From demo-java with MIT License | 5 votes |
private void createSauceDriver(MutableCapabilities capabilities, String methodName) { String username = System.getenv("SAUCE_USERNAME"); String accesskey = System.getenv("SAUCE_ACCESS_KEY"); //Create a map of capabilities called "sauce:options", which contain the info necessary to run on Sauce // Labs, using the credentials stored in the environment variables. Also runs using the new W3C standard. MutableCapabilities sauceOptions = new MutableCapabilities(); sauceOptions.setCapability("username", username); sauceOptions.setCapability("accessKey", accesskey); sauceOptions.setCapability("seleniumVersion", "3.141.59"); sauceOptions.setCapability("name", methodName); sauceOptions.setCapability("build", "parallel-TestNG-cross-browser-and-platform-demo"); //Assign the Sauce Options to the base capabilities capabilities.setCapability("sauce:options", sauceOptions); //Create a new RemoteWebDriver, which will initialize the test execution on Sauce Labs servers String SAUCE_REMOTE_URL = "https://ondemand.saucelabs.com/wd/hub"; try { webDriver.set(new RemoteWebDriver(new URL(SAUCE_REMOTE_URL), capabilities)); } catch (MalformedURLException e) { throw new RuntimeException(e); } sessionId.set(((RemoteWebDriver)webDriver.get()).getSessionId().toString()); // set current sessionId String id = ((RemoteWebDriver) getWebDriver()).getSessionId().toString(); sessionId.set(id); }
Example #17
Source File: ChromeDriverHandler.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Override public MutableCapabilities getOptions(Parameter parameter, Optional<Object> testInstance) throws IOException, IllegalAccessException { ChromeOptions chromeOptions = new ChromeOptions(); if (parameter != null) { // @Arguments Arguments arguments = parameter.getAnnotation(Arguments.class); if (arguments != null) { stream(arguments.value()).forEach(chromeOptions::addArguments); } // @Extensions Extensions extensions = parameter.getAnnotation(Extensions.class); if (extensions != null) { for (String extension : extensions.value()) { chromeOptions.addExtensions(getExtension(extension)); } } // @Binary Binary binary = parameter.getAnnotation(Binary.class); if (binary != null) { chromeOptions.setBinary(binary.value()); } // @Options ChromeOptions optionsFromAnnotatedField = annotationsReader .getFromAnnotatedField(testInstance, Options.class, ChromeOptions.class); if (optionsFromAnnotatedField != null) { chromeOptions = optionsFromAnnotatedField.merge(chromeOptions); } } return chromeOptions; }
Example #18
Source File: DistributorTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void shouldBeAbleToAddANodeAndCreateASession() throws URISyntaxException { URI nodeUri = new URI("http://example:5678"); URI routableUri = new URI("http://localhost:1234"); LocalSessionMap sessions = new LocalSessionMap(tracer, bus); LocalNode node = LocalNode.builder(tracer, bus, routableUri, routableUri, null) .add(caps, new TestSessionFactory((id, c) -> new Session(id, nodeUri, c))) .build(); Distributor distributor = new LocalDistributor( tracer, bus, new PassthroughHttpClient.Factory(node), sessions, null); distributor.add(node); MutableCapabilities sessionCaps = new MutableCapabilities(caps); sessionCaps.setCapability("sausages", "gravy"); try (NewSessionPayload payload = NewSessionPayload.create(sessionCaps)) { Session session = distributor.newSession(createRequest(payload)).getSession(); assertThat(session.getCapabilities()).isEqualTo(sessionCaps); assertThat(session.getUri()).isEqualTo(routableUri); } }
Example #19
Source File: EdgeDriverHandler.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Override public MutableCapabilities getOptions(Parameter parameter, Optional<Object> testInstance) throws IOException, IllegalAccessException { EdgeOptions edgeOptions = new EdgeOptions(); EdgeOptions optionsFromAnnotatedField = annotationsReader .getFromAnnotatedField(testInstance, Options.class, EdgeOptions.class); if (optionsFromAnnotatedField != null) { edgeOptions = optionsFromAnnotatedField; } return edgeOptions; }
Example #20
Source File: SafariDriverHandler.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Override public MutableCapabilities getOptions(Parameter parameter, Optional<Object> testInstance) throws IllegalAccessException { SafariOptions safariOptions = new SafariOptions(); SafariOptions optionsFromAnnotatedField = annotationsReader .getFromAnnotatedField(testInstance, Options.class, SafariOptions.class); if (optionsFromAnnotatedField != null) { safariOptions = optionsFromAnnotatedField; } return safariOptions; }
Example #21
Source File: MobileOptionsTest.java From java-client with Apache License 2.0 | 5 votes |
@Test public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); capabilities.setCapability("newCommandTimeout", 60); mobileOptions = new MobileOptions<>(capabilities); assertEquals("Pixel", mobileOptions.getDeviceName()); assertEquals("10", mobileOptions.getPlatformVersion()); assertEquals(Duration.ofSeconds(60), mobileOptions.getNewCommandTimeout()); }
Example #22
Source File: DriverFactory.java From NoraUi with GNU Affero General Public License v3.0 | 5 votes |
/** * Sets the logging level of the generated web driver. * * @param caps * The web driver's MutableCapabilities (FirefoxOptions) * @param level * The logging level */ private void setLoggingLevel(MutableCapabilities caps) { final LoggingPreferences logPrefs = new LoggingPreferences(); logPrefs.enable(LogType.BROWSER, Level.ALL); logPrefs.enable(LogType.CLIENT, Level.OFF); logPrefs.enable(LogType.DRIVER, Level.OFF); logPrefs.enable(LogType.PERFORMANCE, Level.OFF); logPrefs.enable(LogType.PROFILER, Level.OFF); logPrefs.enable(LogType.SERVER, Level.OFF); caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); }
Example #23
Source File: AndroidOptionsTest.java From java-client with Apache License 2.0 | 5 votes |
@Test public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); capabilities.setCapability("newCommandTimeout", 60); androidOptions = new AndroidOptions(capabilities); assertEquals("Pixel", androidOptions.getDeviceName()); assertEquals("10", androidOptions.getPlatformVersion()); assertEquals(Duration.ofSeconds(60), androidOptions.getNewCommandTimeout()); }
Example #24
Source File: InternetExplorerDriverHandler.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Override public MutableCapabilities getOptions(Parameter parameter, Optional<Object> testInstance) throws IOException, IllegalAccessException { InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions(); InternetExplorerOptions optionsFromAnnotatedField = annotationsReader .getFromAnnotatedField(testInstance, Options.class, InternetExplorerOptions.class); if (optionsFromAnnotatedField != null) { internetExplorerOptions = optionsFromAnnotatedField; } return internetExplorerOptions; }
Example #25
Source File: OperaDriverHandler.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Override public MutableCapabilities getOptions(Parameter parameter, Optional<Object> testInstance) throws IOException, IllegalAccessException { OperaOptions operaOptions = new OperaOptions(); if (parameter != null) { // @Arguments Arguments arguments = parameter.getAnnotation(Arguments.class); if (arguments != null) { stream(arguments.value()).forEach(operaOptions::addArguments); } // @Extensions Extensions extensions = parameter.getAnnotation(Extensions.class); if (extensions != null) { for (String extension : extensions.value()) { operaOptions.addExtensions(getExtension(extension)); } } // @Binary Binary binary = parameter.getAnnotation(Binary.class); if (binary != null) { operaOptions.setBinary(binary.value()); } // @Options OperaOptions optionsFromAnnotatedField = annotationsReader .getFromAnnotatedField(testInstance, Options.class, OperaOptions.class); if (optionsFromAnnotatedField != null) { operaOptions = optionsFromAnnotatedField.merge(operaOptions); } } return operaOptions; }
Example #26
Source File: AppiumDriver.java From java-client with Apache License 2.0 | 5 votes |
@Override protected void startSession(Capabilities capabilities) { super.startSession(capabilities); // The RemoteWebDriver implementation overrides platformName // so we need to restore it back to the original value Object originalPlatformName = capabilities.getCapability(PLATFORM_NAME); Capabilities originalCaps = super.getCapabilities(); if (originalPlatformName != null && originalCaps instanceof MutableCapabilities) { ((MutableCapabilities) super.getCapabilities()).setCapability(PLATFORM_NAME, originalPlatformName); } }
Example #27
Source File: DriverFactory.java From hsac-fitnesse-fixtures with Apache License 2.0 | 5 votes |
static void addDefaultCapabilities(MutableCapabilities capabilities) { Set<String> capabilityNames = capabilities.getCapabilityNames(); if (capabilityNames.contains(CapabilityType.BROWSER_NAME) && !capabilityNames.contains(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR)) { capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); } }
Example #28
Source File: DriverFactory.java From restful-booker-platform with GNU General Public License v3.0 | 5 votes |
private WebDriver prepareRemoteDriver(){ if(System.getenv("SAUCE_USERNAME") == null){ throw new RuntimeException("To use remote driver a Sauce lab account is required. Please assign your Sauce labs account name to the environmental variable 'sauce_username'"); } if(System.getenv("SAUCE_ACCESS_KEY") == null){ throw new RuntimeException("To use remote driver a Sauce lab account is required. Please assign your Sauce labs access key to the environmental variable 'sauce_access_key'"); } String URL = "http://" + System.getenv("SAUCE_USERNAME") + ":" + System.getenv("SAUCE_ACCESS_KEY") + "@ondemand.saucelabs.com:80/wd/hub"; FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setCapability("platformName", "Windows 10"); firefoxOptions.setCapability("browserVersion", "65.0"); MutableCapabilities sauceCaps = new MutableCapabilities(); sauceCaps.setCapability("username", System.getenv("SAUCE_USERNAME")); sauceCaps.setCapability("accessKey", System.getenv("SAUCE_ACCESS_KEY")); sauceCaps.setCapability("seleniumVersion", "3.141.59"); sauceCaps.setCapability("name", "Restful-booker-platform"); firefoxOptions.setCapability("sauce:options", sauceCaps); try { return new RemoteWebDriver(new URL(URL), firefoxOptions); } catch (MalformedURLException e) { throw new RuntimeException("WARN: An error occurred attempting to create a remote driver connection. See the following error: " + e); } }
Example #29
Source File: ExtensionSelenium.java From zap-extensions with Apache License 2.0 | 5 votes |
private static void setCommonOptions( MutableCapabilities capabilities, String proxyAddress, int proxyPort) { capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); // W3C capability capabilities.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true); if (proxyAddress != null) { String httpProxy = proxyAddress + ":" + proxyPort; Proxy proxy = new Proxy(); proxy.setHttpProxy(httpProxy); proxy.setSslProxy(httpProxy); capabilities.setCapability(CapabilityType.PROXY, proxy); } }
Example #30
Source File: RemoteDriverFactory.java From hsac-fitnesse-fixtures with Apache License 2.0 | 5 votes |
@Override public T createDriver() { if (capabilities instanceof MutableCapabilities) { DriverFactory.addDefaultCapabilities((MutableCapabilities) capabilities); } T remoteWebDriver = constr.apply(url, capabilities); FileDetector fd = remoteWebDriver.getFileDetector(); if (fd == null || fd instanceof UselessFileDetector) { remoteWebDriver.setFileDetector(new LocalFileDetector()); } Environment.getInstance().setSymbol(REMOTE_URL_KEY, url.toString()); return remoteWebDriver; }