org.openqa.selenium.Platform#WINDOWS源码实例Demo

下面列出了org.openqa.selenium.Platform#WINDOWS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: senbot   文件: TestEnvironmentTest.java
@Test
public void testEquals_OS() {
    TestEnvironment left = new TestEnvironment(null, null, Platform.WINDOWS);
    TestEnvironment right = new TestEnvironment(null, null, Platform.WINDOWS);

    assertTrue(left.matches(right));

    right = new TestEnvironment(null, null, Platform.LINUX);
    assertFalse(left.matches(right));

    right = new TestEnvironment(null, null, Platform.XP);
    assertTrue(left.matches(right));

    right = new TestEnvironment(null, null, Platform.VISTA);
    assertTrue(left.matches(right));

    right = new TestEnvironment(null, null, Platform.ANY);
    assertTrue(left.matches(right));
}
 
源代码2 项目: senbot   文件: TestEnvironmentTest.java
@Test
public void testCleanupDriver() throws Throwable {
	final WebDriver webDriver = mock(WebDriver.class);
	TestEnvironment env = new TestEnvironment(null, null, Platform.WINDOWS){
		@Override
		public WebDriver getWebDriver(){
			return webDriver;
		}
	};
	
	assertEquals(webDriver, env.getWebDriver());
	
	env.cleanupDriver();
	
	verify(webDriver, times(1)).quit();
	env.cleanupAllDrivers();
}
 
源代码3 项目: senbot   文件: TestEnvironmentTest.java
@Test
public void testIsWebDriverAccessedSince() {
    TestEnvironment env = new TestEnvironment(TestEnvironment.FF, null, Platform.WINDOWS);
  
    long beforeAccess = System.currentTimeMillis() - 1;
    assertFalse(env.isWebDriverAccessedSince(0));
    assertFalse(env.isWebDriverAccessedSince(beforeAccess));

    env.getWebDriver();
    assertTrue(env.isWebDriverAccessedSince(0));
    assertTrue(env.isWebDriverAccessedSince(beforeAccess));
    assertFalse(env.isWebDriverAccessedSince(System.currentTimeMillis()));
    
    env.cleanupAllDrivers();
    
}
 
源代码4 项目: hifive-pitalium   文件: AssumeCapabilityTest.java
@CapabilityFilters({
		@CapabilityFilter(filterGroup = "pc", browserName = BrowserType.IE),
		@CapabilityFilter(platform = Platform.WINDOWS, browserName = { BrowserType.FIREFOX, BrowserType.CHROME }) })
@Test
public void multipleFilters() throws Exception {
	assertAssumed(2, 5, 6, 7, 8);
}
 
源代码5 项目: selenium   文件: DriverFactoryTest.java
@Test
public void testShouldConsiderPlatform() {
  DesiredCapabilities windows = new DesiredCapabilities("browser", "v1", Platform.WINDOWS);
  DesiredCapabilities linux = new DesiredCapabilities("browser", "v1", Platform.LINUX);

  DriverProvider windowsProvider = mockDriverProviderFor(windows);
  DriverProvider linuxProvider = mockDriverProviderFor(linux);

  factory.registerDriverProvider(windowsProvider);
  factory.registerDriverProvider(linuxProvider);

  assertEquals(windowsProvider, factory.getProviderMatching(windows));
  assertEquals(linuxProvider, factory.getProviderMatching(linux));
}
 
源代码6 项目: selenium   文件: CapabilitiesComparatorTest.java
@Test
public void pickingVistaFromVariousLists() {
  Capabilities any = capabilities(BrowserType.IE, "", Platform.ANY, true);
  Capabilities windows = capabilities(BrowserType.IE, "", Platform.WINDOWS, true);
  Capabilities xp = capabilities(BrowserType.IE, "", Platform.XP, true);
  Capabilities vista = capabilities(BrowserType.IE, "", Platform.VISTA, true);

  Platform current = Platform.WINDOWS;
  assertThat(getBestMatch(vista, singletonList(any), current)).isEqualTo(any);
  assertThat(getBestMatch(vista, asList(any, windows), current)).isEqualTo(windows);
  assertThat(getBestMatch(vista, asList(windows, xp, vista), current)).isEqualTo(vista);
  assertThat(getBestMatch(vista, asList(windows, xp), current)).isEqualTo(windows);
  assertThat(getBestMatch(vista, asList(xp, vista), current)).isEqualTo(vista);
  assertThat(getBestMatch(vista, singletonList(xp), current)).isEqualTo(xp);
  assertThat(getBestMatch(vista, singletonList(vista), current)).isEqualTo(vista);

  current = Platform.VISTA;
  assertThat(getBestMatch(vista, singletonList(any), current)).isEqualTo(any);
  assertThat(getBestMatch(vista, asList(any, windows), current)).isEqualTo(windows);
  assertThat(getBestMatch(vista, asList(any, vista), current)).isEqualTo(vista);
  assertThat(getBestMatch(vista, asList(windows, xp, vista), current)).isEqualTo(vista);
  assertThat(getBestMatch(vista, asList(windows, xp), current)).isEqualTo(windows);
  assertThat(getBestMatch(vista, asList(xp, vista), current)).isEqualTo(vista);
  assertThat(getBestMatch(vista, singletonList(xp), current)).isEqualTo(xp);
  assertThat(getBestMatch(vista, singletonList(vista), current)).isEqualTo(vista);

  current = Platform.XP;
  assertThat(getBestMatch(vista, singletonList(any), current)).isEqualTo(any);
  assertThat(getBestMatch(vista, asList(any, windows), current)).isEqualTo(windows);
  assertThat(getBestMatch(vista, asList(any, vista), current)).isEqualTo(vista);
  assertThat(getBestMatch(vista, asList(windows, xp, vista), current)).isEqualTo(vista);
  assertThat(getBestMatch(vista, asList(windows, xp), current)).isEqualTo(windows);
  assertThat(getBestMatch(vista, asList(xp, vista), current)).isEqualTo(vista);
  assertThat(getBestMatch(vista, singletonList(xp), current)).isEqualTo(xp);
  assertThat(getBestMatch(vista, singletonList(vista), current)).isEqualTo(vista);
}
 
源代码7 项目: hifive-pitalium   文件: AssumeCapabilityTest.java
@CapabilityFilter(platform = Platform.WINDOWS)
@Test
public void familyParamWindows() throws Exception {
	assertAssumed(0, 3, 4);
}
 
源代码8 项目: hifive-pitalium   文件: AssumeCapabilityTest.java
@CapabilityFilter(platform = Platform.WINDOWS, browserName = { BrowserType.FIREFOX, BrowserType.CHROME })
@Test
public void platformWindows_browserFirefoxChrome() throws Exception {
	assertAssumed(0, 1, 2, 5, 6, 7, 8);
}
 
源代码9 项目: kurento-java   文件: Browser.java
private void createChromeBrowser(DesiredCapabilities capabilities) throws MalformedURLException {

    if (scope == BrowserScope.LOCAL) {
      // Management of chromedriver
      WebDriverManager.chromedriver().setup();
    }

    // Chrome options
    ChromeOptions options = new ChromeOptions();

    // Chrome extensions
    if (extensions != null && !extensions.isEmpty()) {

      for (Map<String, String> extension : extensions) {
        InputStream is = getExtensionAsInputStream(extension.values().iterator().next());
        if (is != null) {
          try {
            File crx = File.createTempFile(extension.keySet().iterator().next(), ".crx");
            FileUtils.copyInputStreamToFile(is, crx);
            options.addExtensions(crx);
          } catch (Throwable t) {
            log.error("Error loading Chrome extension {} ({} : {})", extension, t.getClass(),
                t.getMessage());
          }
        }
      }
    }

    if (enableScreenCapture) {
      // This flag enables the screen sharing
      options.addArguments("--enable-usermedia-screen-capturing");

      String windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT;
      if (platform != null
          && (platform == Platform.WINDOWS || platform == Platform.XP || platform == Platform.VISTA
              || platform == Platform.WIN8 || platform == Platform.WIN8_1)) {

        windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT_WIN;
      }
      options.addArguments("--auto-select-desktop-capture-source="
          + getProperty(TEST_SCREEN_SHARE_TITLE_PROPERTY, windowTitle));

    } else {
      // This flag avoids grant the camera
      options.addArguments("--use-fake-ui-for-media-stream");
    }

    // This flag avoids warning in Chrome. See:
    // https://code.google.com/p/chromedriver/issues/detail?id=799
    options.addArguments("--test-type");

    // To avoid problems with DevToolsActivePort
    options.addArguments("--no-sandbox");

    if (protocol == Protocol.FILE) {
      // This flag allows reading local files in video tags
      options.addArguments("--allow-file-access-from-files");
    }

    if (!usePhysicalCam) {
      // This flag makes using a synthetic video (green with
      // spinner) in WebRTC. Or it is needed to combine with
      // use-file-for-fake-video-capture to use a file faking the
      // cam
      options.addArguments("--use-fake-device-for-media-stream=fps=30");

      if (video != null && (isLocal() || isDocker() || isElastest())) {

        if (!Files.exists(Paths.get(video))) {
          throw new RuntimeException("Trying to create a browser using video file " + video
              + ", but this file doesn't exist.");
        }

        File videoFile = new File(video);
        log.debug("Using video {} in browser {} (exists {}, {} bytes, can read {})", video, id,
            videoFile.exists(), videoFile.length(), videoFile.canRead());
        options.addArguments("--use-file-for-fake-video-capture=" + video);
      }
    }

    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());

    createDriver(capabilities, options);
  }