Java 类org.openqa.selenium.safari.SafariOptions 实例源码

项目:givemeadriver    文件:SafariCapabilitiesConverterTest.java   
@Test
public void settingBrowserSize() {
    // given
    WebDriverProperties properties = new WebDriverProperties();
    properties.setProperty("browserSize", "1690x1000");

    // when
    Capabilities convertedCapabilities = safariCapabilitiesConverter.convert(properties);

    // then
    // expected safari options
    SafariOptions expectedSafariOptions = new SafariOptions();
    expectedSafariOptions.setCapability(CAPABILITY_AUTOCLOSE, false);
    expectedSafariOptions.setCapability(CAPABILITY_BROWSER_SIZE, "1690x1000");

    assertThat(convertedCapabilities.asMap()).isEqualTo(expectedSafariOptions.asMap());

}
项目:selenium-jupiter    文件:SafariDriverHandler.java   
@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);
    }
}
项目:teasy    文件:SeleniumTestExecutionListener.java   
private WebDriver safariTechnologyPreview(Settings settings, DesiredCapabilities customDesiredCapabilities) throws MalformedURLException {
    DesiredCapabilities desiredCapabilities = DesiredCapabilities.safari();
    SafariOptions safariOptions = new SafariOptions();
    safariOptions.setUseCleanSession(true);
    safariOptions.setUseTechnologyPreview(true);
    desiredCapabilities.setCapability(SafariOptions.CAPABILITY, safariOptions);
    if (!customDesiredCapabilities.asMap().isEmpty()) {
        desiredCapabilities.merge(customDesiredCapabilities);
    }
    RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(settings.getGridHubUrl()), desiredCapabilities);
    remoteWebDriver.setFileDetector(new LocalFileDetector());
    return remoteWebDriver;
}
项目:givemeadriver    文件:SafariCapabilitiesConverter.java   
@Override
public Capabilities convert(WebDriverProperties properties) {
    SafariOptions safariOptions = new SafariOptions();

    // general options for logging purpose
    safariOptions.setCapability(CAPABILITY_AUTOCLOSE, properties.isAutoClose());
    if (isNotEmpty(properties.getBrowserSize())) {
        safariOptions.setCapability(CAPABILITY_BROWSER_SIZE, properties.getBrowserSize());
    }

    return safariOptions;
}
项目:selenium-jupiter    文件:SafariAnnotationReaderTest.java   
@ParameterizedTest
@MethodSource("testClassProvider")
@SuppressWarnings("deprecation")
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);

    assertTrue(safariOptions.getUseCleanSession());
    assertFalse(safariOptions.getUseTechnologyPreview());
}
项目: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;
}
项目:frameworkium-core    文件:SafariImpl.java   
@Override
public SafariOptions getCapabilities() {
    if (Driver.isMobile()) {
        return new SafariOptions();
    } else {
        SafariOptions safariOptions = new SafariOptions();
        safariOptions.setCapability("safari.cleanSession", true);
        return safariOptions;
    }
}
项目:frameworkium-core    文件:SafariImpl.java   
@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));
    }
}
项目:KITE    文件:WebDriverFactory.java   
/**
 * Creates a Capabilities object based on the given Browser object.
 *
 * @param browser Browser
 * @param testName name for individual test case
 * @return Capabilities
 */
private static Capabilities createCapabilities(Browser browser, String testName) {

  DesiredCapabilities capabilities = new DesiredCapabilities();

  capabilities.setBrowserName(browser.getBrowserName());
  if (browser.getVersion() != null)
    capabilities.setVersion(browser.getVersion());
  if (browser.getPlatform() != null)
    capabilities.setCapability("platform", browser.getPlatform());
  // Remote test identifier
  capabilities.setCapability("name", testName);

  switch (browser.getBrowserName()) {
    case "chrome":
      // capabilities = DesiredCapabilities.chrome();
      ChromeOptions chromeOptions = new ChromeOptions();
      chromeOptions.addArguments("use-fake-ui-for-media-stream");
      chromeOptions.addArguments("use-fake-device-for-media-stream");
      /*
       * chromeOptions.addArguments("no-sandbox"); chromeOptions.addArguments("disable-infobars");
       * chromeOptions.addArguments("test-type=browser");
       * chromeOptions.addArguments("disable-extensions");
       * chromeOptions.addArguments("--js-flags=--expose-gc");
       * chromeOptions.addArguments("--disable-default-apps");
       * chromeOptions.addArguments("--disable-popup-blocking");
       * chromeOptions.addArguments("--enable-precise-memory-info");
       */
      capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
      break;
    case "firefox":
      // capabilities = DesiredCapabilities.firefox();
      FirefoxProfile firefoxProfile = new FirefoxProfile();
      firefoxProfile.setPreference("media.navigator.streams.fake", true);
      FirefoxOptions firefoxOptions = new FirefoxOptions();
      firefoxOptions.setProfile(firefoxProfile);
      capabilities.merge(firefoxOptions.toCapabilities());
      /*
       * capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
       */
      break;
    case "MicrosoftEdge":
      // capabilities = DesiredCapabilities.edge();
      capabilities.setCapability("avoidProxy", true);
      break;
    case "safari":
      // capabilities = DesiredCapabilities.safari();
      SafariOptions options = new SafariOptions();
      options.setUseTechnologyPreview(true);
      capabilities.setCapability(SafariOptions.CAPABILITY, options);
      break;
  }

  // Capabilities for mobile browsers
  Mobile mobile = browser.getMobile();
  if (mobile != null) {
    capabilities.setCapability("deviceName", mobile.getDeviceName());
    capabilities.setCapability("platformName", mobile.getPlatformName());
    capabilities.setCapability("platformVersion", mobile.getPlatformVersion());
    if (mobile.getPlatformName().equalsIgnoreCase("iOS")) {
      capabilities.setCapability("automationName", "XCUITest");
    } else {
      capabilities.setCapability("autoGrantPermissions", true);
      capabilities.setCapability("noReset", true);
    }
  }

  return capabilities;

}
项目:givemeadriver    文件:SafariDriverFactory.java   
@Override
public WebDriver createDriver(Capabilities capabilities) {
    return new SafariDriver((SafariOptions) capabilities);
}
项目:SwiftLite    文件:WebDriverFactory.java   
@Override
public WebDriver create() {
    SafariOptions safariOptions = new SafariOptions(); 
    safariOptions.setUseCleanSession(true);     
    return new SafariDriver(safariOptions);
}
项目:darcy-webdriver    文件:SafariBrowserFactory.java   
public SafariBrowserFactory usingOptions(SafariOptions options) {
    safariOptions = options;
    return this;
}
项目:minium    文件:WebDriverFactory.java   
@Override
public WebDriver create(WebDriverFactory webDriverFactory, DesiredCapabilities desiredCapabilities) {
    return new SafariDriver(new SafariOptions().merge(desiredCapabilities));
}
项目:easyium-java    文件:SafariDriver.java   
/**
 * Initializes a new SafariDriver using the specified {@link SafariOptions}.
 *
 * @param safariOptions safari specific options / capabilities for the driver
 */
public SafariDriver(SafariOptions safariOptions) {
    super(new org.openqa.selenium.safari.SafariDriver(safariOptions));
}