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

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

源代码1 项目: hifive-pitalium   文件: AssumeCapability.java
/**
 * {@link Platform#family()}から辿れるPlatformの親一覧を取得します。
 * 
 * @param platform 対象のPlatform
 * @return 引数のPlatformと、引数のPlatformの親Platform一覧
 */
private static Collection<Platform> toPlatformFamily(Platform platform) {
	Set<Platform> platforms = EnumSet.noneOf(Platform.class);
	if (platform == null) {
		return platforms;
	}

	platforms.add(platform);

	Platform parent = platform.family();
	while (parent != null && parent != Platform.ANY) {
		platforms.add(parent);
		parent = parent.family();
	}
	return platforms;
}
 
源代码2 项目: selenium   文件: CapabilitiesComparatorTest.java
@Test
public void shouldPickCorrectBrowser() {
  Capabilities chrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY);
  Capabilities firefox = new DesiredCapabilities(BrowserType.FIREFOX, "10", Platform.ANY);
  Capabilities opera = new DesiredCapabilities(BrowserType.OPERA_BLINK, "10", Platform.ANY);
  List<Capabilities> list = asList(chrome, firefox, opera);

  DesiredCapabilities desired = new DesiredCapabilities();

  desired.setBrowserName(BrowserType.CHROME);
  assertThat(getBestMatch(desired, list)).isEqualTo(chrome);

  desired.setBrowserName(BrowserType.FIREFOX);
  assertThat(getBestMatch(desired, list)).isEqualTo(firefox);

  desired.setBrowserName(BrowserType.OPERA_BLINK);
  assertThat(getBestMatch(desired, list)).isEqualTo(opera);
}
 
源代码3 项目: selenium   文件: CapabilitiesComparatorTest.java
@Test
public void currentPlatformCheckDoesNotTrumpExactPlatformMatch() {
  Capabilities chromeUnix = capabilities(BrowserType.CHROME, "", Platform.UNIX, true);
  Capabilities chromeVista = capabilities(BrowserType.CHROME, "", Platform.VISTA, true);
  Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY);

  List<Capabilities> allCaps = asList(anyChrome, chromeVista, chromeUnix);

  assertThat(getBestMatch(chromeVista, allCaps, Platform.UNIX)).isEqualTo(chromeVista);
  assertThat(getBestMatch(chromeVista, allCaps, Platform.LINUX)).isEqualTo(chromeVista);
  assertThat(getBestMatch(chromeVista, allCaps, Platform.MAC)).isEqualTo(chromeVista);

  assertThat(getBestMatch(chromeUnix, allCaps, Platform.MAC)).isEqualTo(chromeUnix);
  assertThat(getBestMatch(chromeUnix, allCaps, Platform.VISTA)).isEqualTo(chromeUnix);
  assertThat(getBestMatch(chromeUnix, allCaps, Platform.WINDOWS)).isEqualTo(chromeUnix);
}
 
源代码4 项目: selenium   文件: CapabilitiesComparatorTest.java
@Test
public void ignoresVersionStringIfEmpty() {
  Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY);
  Capabilities chromeNoVersion = new DesiredCapabilities() {{
    setBrowserName(BrowserType.CHROME);
    setPlatform(Platform.UNIX);
  }};
  Capabilities chromeEmptyVersion = new DesiredCapabilities(chromeNoVersion) {{
    setVersion("");
  }};

  List<Capabilities> allCaps = asList(anyChrome, chromeNoVersion);

  assertThat(getBestMatch(chromeEmptyVersion, allCaps, Platform.UNIX)).isEqualTo(chromeNoVersion);
  assertThat(getBestMatch(chromeNoVersion, allCaps, Platform.UNIX)).isEqualTo(chromeNoVersion);
  // Unix does not match windows.
  assertThat(getBestMatch(anyChrome, allCaps, Platform.WINDOWS)).isEqualTo(anyChrome);
}
 
源代码5 项目: marathonv5   文件: LaunchJavaCommandLineTest.java
@BeforeClass
public void createDriver() {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE);
    File f = findFile();
    profile.addClassPath(f);
    profile.setMainClass("com.sun.swingset3.SwingSet3");
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}
 
源代码6 项目: marathonv5   文件: LaunchCommandLineTest.java
@BeforeClass
public void createDriver() {
    JavaProfile profile = new JavaProfile(LaunchMode.COMMAND_LINE);
    File f = findFile();
    profile.setCommand(f.getAbsolutePath());
    profile.addApplicationArguments("Argument1");
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}
 
源代码7 项目: marathonv5   文件: LaunchJavaCommandLineTest.java
@BeforeMethod
public void createDriver() {
    System.setProperty(Constants.PROP_PROJECT_FRAMEWORK, Constants.FRAMEWORK_SWING);
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE);
    File f = findFile();
    profile.addClassPath(f);
    profile.setRecordingPort(startRecordingServer());
    profile.setMainClass("com.sun.swingset3.SwingSet3");
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}
 
源代码8 项目: marathonv5   文件: LaunchCommandLineTest.java
@BeforeClass
public void createDriver() {
    System.setProperty(Constants.PROP_PROJECT_FRAMEWORK, Constants.FRAMEWORK_SWING);
    JavaProfile profile = new JavaProfile(LaunchMode.COMMAND_LINE);
    File f = findFile();
    profile.setCommand(f.getAbsolutePath());
    profile.setRecordingPort(startRecordingServer());
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}
 
源代码9 项目: KITE   文件: PaasHandler.java
/**
 * Search.
 *
 * @param client the client
 *
 * @return true, if successful
 *
 * @throws SQLException the SQL exception
 */
public boolean search(Client client) throws SQLException {
  boolean result = false;
  if (!client.isApp()) {
    String browserName = client.getBrowserSpecs().getBrowserName();
    String version = client.getBrowserSpecs().getVersion().split("\\.")[0].trim();
    Platform platform = client.getBrowserSpecs().getPlatform();
    
    String sql = "SELECT * FROM " + this.paas.getType().name() + " WHERE BROWSER = '" + browserName + "'";
    if (version != null && !version.isEmpty())
      sql += " AND VERSION LIKE '" + version + "%'";
    if (platform != Platform.ANY) {
      Platform family = platform.family();
      if (family == null)
        sql += " AND PLATFORM_TYPE = '" + platform.name() + "'";
      else
        sql += " AND PLATFORM = '" + platform.name() + "'";
    }
    sql += ";";
    
    Connection c = null;
    Statement s = null;
    ResultSet rs = null;
    try {
      c = this.getDatabaseConnection();
      s = c.createStatement();
      rs = s.executeQuery(sql);
      if (rs.next())
        result = true;
    } finally {
      Utils.closeDBResources(s, rs);
      if (c != null)
        c.close();
    }
  }
  return result;
}
 
static Queue<RunContext> getTestCaseRunManager() {
    Queue<RunContext> execQ = new LinkedList<>();
    RunContext exe = new RunContext();
    exe.Scenario = globalSettings.getScenario();
    exe.TestCase = globalSettings.getTestCase();
    exe.Description = "Test Run";
    exe.BrowserName = globalSettings.getBrowser();
    exe.Browser = Browser.fromString(exe.BrowserName);
    exe.Platform = Platform.ANY;
    exe.BrowserVersion = "default";
    exe.Iteration = "Single";
    exe.print();
    execQ.add(exe);
    return execQ;
}
 
static Platform getPlatform(String platform) {
     if (platform != null && !platform.trim().isEmpty()) {
         if (platform.contains("WIN8_1")) {
	return Platform.fromString("WIN8.1");
}
         if (platform.contains("_")) {
             platform = platform.replace("_", " ");
             return Platform.fromString(platform.toUpperCase());
         } else {
             return Platform.fromString(platform.toUpperCase());
         }
     }
     return Platform.ANY;
 }
 
源代码12 项目: webtester2-core   文件: RemoteFactory.java
@Override
public Browser createBrowser() {
    String browserName = configuration.getRemoteBrowserName();
    String browserVersion = configuration.getRemoteBrowserVersion();
    DesiredCapabilities capabilities = new DesiredCapabilities(browserName, browserVersion, Platform.ANY);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    capabilities.setCapability(CapabilityType.HAS_NATIVE_EVENTS, false);
    capabilities.setCapability("marionette", configuration.getRemoteFirefoxMarionette());
    setOptionalProxyConfiguration(capabilities);
    return createBrowser(capabilities);
}
 
源代码13 项目: selenium   文件: CapabilitiesComparatorTest.java
@Test
public void matchesWithPreferenceToCurrentPlatform() {
  Capabilities chromeUnix = capabilities(BrowserType.CHROME, "", Platform.UNIX, true);
  Capabilities chromeVista = capabilities(BrowserType.CHROME, "", Platform.VISTA, true);
  Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "", Platform.ANY);

  List<Capabilities> allCaps = asList(anyChrome, chromeVista, chromeUnix,
      // This last option should never match.
      new DesiredCapabilities(BrowserType.FIREFOX, "10", Platform.ANY));

  // Should match to corresponding platform.
  assertThat(getBestMatch(anyChrome, allCaps, Platform.UNIX)).isEqualTo(chromeUnix);
  assertThat(getBestMatch(chromeUnix, allCaps, Platform.UNIX)).isEqualTo(chromeUnix);

  assertThat(getBestMatch(anyChrome, allCaps, Platform.LINUX)).isEqualTo(chromeUnix);
  assertThat(getBestMatch(chromeUnix, allCaps, Platform.LINUX)).isEqualTo(chromeUnix);

  assertThat(getBestMatch(anyChrome, allCaps, Platform.VISTA)).isEqualTo(chromeVista);
  assertThat(getBestMatch(chromeVista, allCaps, Platform.VISTA)).isEqualTo(chromeVista);

  assertThat(getBestMatch(anyChrome, allCaps, Platform.WINDOWS)).isEqualTo(chromeVista);
  assertThat(getBestMatch(chromeVista, allCaps, Platform.WINDOWS)).isEqualTo(chromeVista);

  // No configs registered to current platform, should fallback to normal matching rules.
  assertThat(getBestMatch(anyChrome, allCaps, Platform.MAC)).isEqualTo(anyChrome);
  assertThat(getBestMatch(anyChrome, allCaps, Platform.XP)).isEqualTo(anyChrome);
}
 
源代码14 项目: selenium-api   文件: PlatformMatcherTest.java
@DataProvider
public Object[][] platforms() {
    return new Object[][]{
            {"win7", Platform.VISTA, true},
            {"win7", "windows 7", true},
            {"vista", Platform.VISTA, true},
            {"darwin", Platform.MAC, true},
            {Platform.ANY, Platform.LINUX, true},
            {"linux", Platform.LINUX, true},
            {"linux", Platform.UNIX, false},
            {null, Platform.XP, true},
    };
}
 
源代码15 项目: selenium   文件: CapabilitiesComparatorTest.java
@Test
public void absentExactMatchPrefersItemsInInputOrder() {
  Capabilities chromeWindows = capabilities(BrowserType.CHROME, "", Platform.WINDOWS, true);
  Capabilities chromeVista = capabilities(BrowserType.CHROME, "", Platform.VISTA, true);
  Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY);

  List<Capabilities> allCaps = asList(chromeWindows, chromeVista);
  List<Capabilities> reversedCaps = Lists.reverse(allCaps);

  assertThat(getBestMatch(anyChrome, allCaps, Platform.UNIX)).isEqualTo(chromeWindows);
  assertThat(getBestMatch(anyChrome, reversedCaps, Platform.UNIX)).isEqualTo(chromeVista);
}
 
源代码16 项目: selenium   文件: DriverFactoryTest.java
@Test
public void testShouldMatchAgainstAnyPlatformWhenRequestingAny() {
  DesiredCapabilities windowsVista = new DesiredCapabilities("browser", "v1", Platform.VISTA);
  DesiredCapabilities windowsXp = new DesiredCapabilities("browser", "v1", Platform.XP);
  DesiredCapabilities anyWindows = new DesiredCapabilities("browser", "v1", Platform.ANY);

  DriverProvider provider = mockDriverProviderFor(windowsVista);

  factory.registerDriverProvider(provider);

  assertEquals(provider, factory.getProviderMatching(windowsVista));
  assertEquals(provider, factory.getProviderMatching(anyWindows));
  assertEquals("Should always get a match if a driver has been registered",
               provider, factory.getProviderMatching(windowsXp));
}
 
源代码17 项目: hifive-pitalium   文件: AssumeCapabilityTest.java
@CapabilityFilter(platform = Platform.ANY)
@Test
public void anyParam() throws Exception {
	assertNotAssumed();
}
 
源代码18 项目: selenium   文件: DesiredCapabilities.java
@Deprecated
public static DesiredCapabilities htmlUnit() {
  return new DesiredCapabilities(BrowserType.HTMLUNIT, "", Platform.ANY);
}
 
源代码19 项目: selenium   文件: CapabilitiesComparator.java
public CapabilitiesComparator(final Capabilities desiredCapabilities,
                              final Platform currentPlatform) {
  final CapabilityScorer<String> browserNameScorer =
      new CapabilityScorer<>(desiredCapabilities.getBrowserName());
  Comparator<Capabilities> byBrowserName =
      Comparator.comparingInt(c -> browserNameScorer.score(c.getBrowserName()));

  final CapabilityScorer<String> versionScorer =
      new VersionScorer(desiredCapabilities.getVersion());
  Comparator<Capabilities> byVersion =
      Comparator.comparingInt(c -> versionScorer.score(c.getVersion()));

  final CapabilityScorer<Boolean> jsScorer =
      new CapabilityScorer<>(desiredCapabilities.is(SUPPORTS_JAVASCRIPT));
  Comparator<Capabilities> byJavaScript =
      Comparator.comparingInt(c -> jsScorer.score(c.is(SUPPORTS_JAVASCRIPT)));

  Platform desiredPlatform = desiredCapabilities.getPlatform();
  if (desiredPlatform == null) {
    desiredPlatform = Platform.ANY;
  }

  final CapabilityScorer<Platform> currentPlatformScorer =
      new CurrentPlatformScorer(currentPlatform, desiredPlatform);
  Comparator<Capabilities> byCurrentPlatform =
      Comparator.comparingInt(c -> currentPlatformScorer.score(c.getPlatform()));

  final CapabilityScorer<Platform> strictPlatformScorer =
      new CapabilityScorer<>(desiredPlatform);
  Comparator<Capabilities> byStrictPlatform =
      Comparator.comparingInt(c -> strictPlatformScorer.score(c.getPlatform()));

  final CapabilityScorer<Platform> fuzzyPlatformScorer =
      new FuzzyPlatformScorer(desiredPlatform);
  Comparator<Capabilities> byFuzzyPlatform =
      Comparator.comparingInt(c -> fuzzyPlatformScorer.score(c.getPlatform()));

  compareWith = Ordering.compound(Arrays.asList(
      byBrowserName,
      byVersion,
      byJavaScript,
      byCurrentPlatform,
      byStrictPlatform,
      byFuzzyPlatform));
}
 
源代码20 项目: selenium   文件: CapabilitiesComparator.java
private static boolean isNullOrAny(Platform platform) {
  return null == platform || Platform.ANY == platform;
}