org.openqa.selenium.safari.SafariOptions Java Examples
The following examples show how to use
org.openqa.selenium.safari.SafariOptions.
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: SafariDriverHandler.java From selenium-jupiter with Apache License 2.0 | 6 votes |
@Override public void resolve() { try { Optional<Object> testInstance = context.getTestInstance(); Optional<Capabilities> capabilities = annotationsReader .getCapabilities(parameter, testInstance); SafariOptions safariOptions = (SafariOptions) getOptions(parameter, testInstance); if (capabilities.isPresent()) { safariOptions.merge(capabilities.get()); } object = new SafariDriver(safariOptions); } catch (Exception e) { handleException(e); } }
Example #2
Source File: SafariAnnotationReaderTest.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@ParameterizedTest @MethodSource("testClassProvider") void testSafariOptions(Class<?> testClass) throws Exception { Parameter parameter = testClass .getMethod("safariTest", SafariDriver.class).getParameters()[0]; Optional<Object> testInstance = Optional.of(testClass.newInstance()); SafariOptions safariOptions = (SafariOptions) annotationsReader .getOptions(parameter, testInstance); assertFalse(safariOptions.getUseTechnologyPreview()); }
Example #3
Source File: InternalSelenseTestBase.java From selenium with Apache License 2.0 | 5 votes |
private Capabilities createCapabilities() { String property = System.getProperty("selenium.browser", "ff"); Browser browser = Browser.detect(); switch (browser) { case CHROME: return new ChromeOptions(); case EDGE: return new EdgeHtmlOptions(); case CHROMIUMEDGE: return new EdgeOptions(); case IE: return new InternetExplorerOptions(); case FIREFOX: case MARIONETTE: return new FirefoxOptions(); case OPERA: case OPERABLINK: return new OperaOptions(); case SAFARI: return new SafariOptions(); default: fail("Attempt to use an unsupported browser: " + property); // we never get here, but keep null checks happy anyway return new DesiredCapabilities(); } }
Example #4
Source File: SafariImpl.java From frameworkium-core with Apache License 2.0 | 5 votes |
@Override public WebDriver getWebDriver(Capabilities capabilities) { if (Driver.isMobile()) { throw new IllegalArgumentException( "seleniumGridURL or sauceUser and sauceKey must be specified when running on iOS"); } else { return new SafariDriver(new SafariOptions(capabilities)); } }
Example #5
Source File: SafariImpl.java From frameworkium-core with Apache License 2.0 | 5 votes |
@Override public SafariOptions getCapabilities() { if (Driver.isMobile()) { return new SafariOptions(); } else { SafariOptions safariOptions = new SafariOptions(); safariOptions.setCapability("safari.cleanSession", true); return safariOptions; } }
Example #6
Source File: DefaultLocalDriverProviderTest.java From webdriver-factory with Apache License 2.0 | 5 votes |
@Test @EnabledOnOs(OS.MAC) @DisabledIfEnvironmentVariable(named = "CI", matches = "true") void canInstantiateSafariDriverWithSafariOptions() { driver = provider.createDriver(new SafariOptions()); assertTrue(driver instanceof SafariDriver); }
Example #7
Source File: CustomDriverProvider.java From akita with Apache License 2.0 | 5 votes |
/** * Задает options для запуска Safari драйвера * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension * * @return SafariOptions */ private SafariOptions getSafariDriverOptions(DesiredCapabilities capabilities) { log.info("---------------Safari Driver---------------------"); SafariOptions safariOptions = new SafariOptions(); safariOptions.setCapability(CapabilityType.BROWSER_VERSION, loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST)); safariOptions.merge(capabilities); return safariOptions; }
Example #8
Source File: BrowserDriver.java From SWET with MIT License | 5 votes |
private static DesiredCapabilities capabilitiesSafari() { DesiredCapabilities capabilities = DesiredCapabilities.safari(); SafariOptions options = new SafariOptions(); // TODO: need to conditionally compile: // With Selenium 3.13.x // setUseCleanSession // no longer not exist in org.openqa.selenium.safari.SafariOptions // options.setUseCleanSession(true); capabilities.setCapability(SafariOptions.CAPABILITY, options); return capabilities; }
Example #9
Source File: SafariAnnotationReaderTest.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Test void testAnnotatedSafariOptionsIsSelectedOverOtherAnnotatedOptions() throws Exception { Optional<Object> testInstance = Optional .of(new ClassWithMultipleOptions()); SafariOptions safariOptions = (SafariOptions) annotationsReader .getOptions(null, testInstance); assertThat(safariOptions, notNullValue()); }
Example #10
Source File: WebDriverTypeTests.java From vividus with Apache License 2.0 | 5 votes |
@Test @PrepareForTest(fullyQualifiedNames = "org.vividus.selenium.WebDriverType$4") public void testGetSafariWebDriver() throws Exception { DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); SafariDriver expected = mock(SafariDriver.class); whenNew(SafariDriver.class).withParameterTypes(SafariOptions.class) .withArguments(SafariOptions.fromCapabilities(desiredCapabilities)).thenReturn(expected); WebDriver actual = WebDriverType.SAFARI.getWebDriver(desiredCapabilities, new WebDriverConfiguration()); assertEquals(expected, actual); }
Example #11
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 #12
Source File: SetProxyForWebDriver.java From neodymium-library with MIT License | 5 votes |
@Test public void testSafari() { DesiredCapabilities capabilities = createCapabilitiesWithProxy(); SafariOptions options = new SafariOptions(); options.merge(capabilities); Assert.assertTrue(options.getCapability(CapabilityType.PROXY) != null); }
Example #13
Source File: WebDriverFactory.java From KITE with Apache License 2.0 | 5 votes |
/** * Build capabilities for client web driver * * @param client the Client object * @return capabilities appium driver */ private static MutableCapabilities buildBrowserCapabilities(Client client) { MutableCapabilities capabilities = new MutableCapabilities(); BrowserSpecs specs = client.getBrowserSpecs(); if (specs.getVersion() != null) { capabilities.setCapability(CapabilityType.VERSION, specs.getVersion()); } if (specs.getPlatform() != null) { capabilities.setCapability(CapabilityType.PLATFORM_NAME, specs.getPlatform()); } // if (client.getCapability().getGateway().toString() != null && !"none".equalsIgnoreCase(client.getCapability().getGateway().toString())) { // capabilities.setCapability("gateway", client.getCapability().getGateway().toString()); // } // Only consider next code block if this is a client. switch (specs.getBrowserName()) { case "chrome": capabilities.setCapability(ChromeOptions.CAPABILITY, setCommonChromeOptions(client.getCapability(), specs)); break; case "firefox": capabilities.merge(setCommonFirefoxOptions(client.getCapability(), specs)); break; case "MicrosoftEdge": EdgeOptions MicrosoftEdgeOptions = new EdgeOptions(); capabilities.setCapability("edgeOptions", MicrosoftEdgeOptions); capabilities.setCapability("avoidProxy", true); break; case "safari": SafariOptions options = new SafariOptions(); options.setUseTechnologyPreview(client.getCapability().isTechnologyPreview()); capabilities.setCapability(SafariOptions.CAPABILITY, options); break; default: capabilities.setCapability(CapabilityType.BROWSER_NAME, specs.getBrowserName()); break; } // Add log preference to webdriver // TODO put log preference into config file LoggingPreferences logPrefs = new LoggingPreferences(); logPrefs.enable(LogType.BROWSER, Level.ALL); capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); // capabilities.setCapability("goog:loggingPrefs", logPrefs); // Capabilities for mobile client/app if (specs.getPlatform().toString().equalsIgnoreCase("android") ||specs.getPlatform().toString().equalsIgnoreCase("ios")) { // deviceName: // On iOS, this should be one of the valid devices returned by instruments with instruments -s devices. // On Android this capability is currently ignored, though it remains required. capabilities.setCapability("deviceName", specs.getDeviceName()); capabilities.setCapability("platformName", specs.getPlatform()); capabilities.setCapability("platformVersion", specs.getPlatformVersion()); if (specs.getPlatform().name().equalsIgnoreCase("ios")) { capabilities.setCapability("automationName", "XCUITest"); capabilities.setCapability("autoAcceptAlerts", true); } else { capabilities.setCapability("autoGrantPermissions", true); capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 300); } capabilities.setCapability("noReset", true); } return capabilities; }
Example #14
Source File: SafariTechPreviewCaps.java From teasy with MIT License | 5 votes |
public MutableCapabilities get() { DesiredCapabilities safariCaps = DesiredCapabilities.safari(); SafariOptions options = new SafariOptions(); options.setUseTechnologyPreview(true); safariCaps.setCapability(SafariOptions.CAPABILITY, options); setLoggingPrefs(safariCaps); if (!this.customCaps.asMap().isEmpty()) { safariCaps.merge(this.customCaps); } return safariCaps; }
Example #15
Source File: WebDriverCapabilities.java From QVisual with Apache License 2.0 | 5 votes |
/** * Download https://developer.apple.com/safari/download/ and activate menu Develop with enable Allow Remote Automation */ private void setupSafari() { SafariOptions safariOptions = new SafariOptions(); safariOptions.setUseTechnologyPreview(true); capabilities.merge(safariOptions); }
Example #16
Source File: Browser.java From coteafs-selenium with Apache License 2.0 | 5 votes |
private static WebDriver setupSafariDriver() { LOG.i("Setting up Safari driver..."); if (!OS.isMac()) { Assert.fail("Safari is not supported."); } if (appSetting().isHeadlessMode()) { LOG.w("Safari does not support Headless mode. Hence, ignoring the same..."); } final SafariOptions options = new SafariOptions(); return new SafariDriver(options); }
Example #17
Source File: SafariDriverCreator.java From bobcat with Apache License 2.0 | 4 votes |
@Override public WebDriver create(Capabilities capabilities) { LOG.info("Starting the initialization of '{}' WebDriver instance", ID); LOG.debug("Initializing WebDriver with following capabilities: {}", capabilities); return new SafariDriver(new SafariOptions(capabilities)); }
Example #18
Source File: DefaultLocalDriverProvider.java From webdriver-factory with Apache License 2.0 | 4 votes |
public WebDriver createDriver(SafariOptions options) { return new SafariDriver(options); }
Example #19
Source File: MacSafariCaps.java From teasy with MIT License | 4 votes |
@Override public MutableCapabilities get() { return new SafariOptions().merge(customCaps); }
Example #20
Source File: SafariBrowserFactory.java From darcy-webdriver with GNU General Public License v3.0 | 4 votes |
public SafariBrowserFactory usingOptions(SafariOptions options) { safariOptions = options; return this; }
Example #21
Source File: SafariSettings.java From aquality-selenium-java with Apache License 2.0 | 4 votes |
@Override public SafariOptions getCapabilities() { SafariOptions safariOptions = new SafariOptions(); setCapabilities(safariOptions); return safariOptions; }