Java Code Examples for org.openqa.selenium.Platform#ANY
The following examples show how to use
org.openqa.selenium.Platform#ANY .
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: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 6 votes |
@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); }
Example 3
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 6 votes |
@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); }
Example 4
Source File: AssumeCapability.java From hifive-pitalium with Apache License 2.0 | 6 votes |
/** * {@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; }
Example 5
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 5 votes |
@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); }
Example 6
Source File: DriverFactoryTest.java From selenium with Apache License 2.0 | 5 votes |
@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)); }
Example 7
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 5 votes |
@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); }
Example 8
Source File: PlatformMatcherTest.java From selenium-api with MIT License | 5 votes |
@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}, }; }
Example 9
Source File: LaunchJavaCommandLineTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: RemoteFactory.java From webtester2-core with Apache License 2.0 | 5 votes |
@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); }
Example 11
Source File: RunManager.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
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; }
Example 12
Source File: RunManager.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
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; }
Example 13
Source File: PaasHandler.java From KITE with Apache License 2.0 | 5 votes |
/** * 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; }
Example 14
Source File: LaunchCommandLineTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@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); }
Example 15
Source File: LaunchJavaCommandLineTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@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); }
Example 16
Source File: LaunchCommandLineTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@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); }
Example 17
Source File: AssumeCapabilityTest.java From hifive-pitalium with Apache License 2.0 | 4 votes |
@CapabilityFilter(platform = Platform.ANY) @Test public void anyParam() throws Exception { assertNotAssumed(); }
Example 18
Source File: DesiredCapabilities.java From selenium with Apache License 2.0 | 4 votes |
@Deprecated public static DesiredCapabilities htmlUnit() { return new DesiredCapabilities(BrowserType.HTMLUNIT, "", Platform.ANY); }
Example 19
Source File: CapabilitiesComparator.java From selenium with Apache License 2.0 | 4 votes |
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)); }
Example 20
Source File: CapabilitiesComparator.java From selenium with Apache License 2.0 | 4 votes |
private static boolean isNullOrAny(Platform platform) { return null == platform || Platform.ANY == platform; }