Java Code Examples for org.openqa.selenium.Capabilities#is()
The following examples show how to use
org.openqa.selenium.Capabilities#is() .
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: DefaultSession.java From selenium with Apache License 2.0 | 6 votes |
private static boolean isQuietModeEnabled( BrowserCreator browserCreator, Capabilities capabilities) { if (browserCreator.isAndroid()) { return true; } boolean propertySaysQuiet = "true".equalsIgnoreCase(System.getProperty(QUIET_EXCEPTIONS_KEY)); if (capabilities == null) { return propertySaysQuiet; } if (capabilities.is(QUIET_EXCEPTIONS_KEY)) { return true; } Object cap = capabilities.asMap().get(QUIET_EXCEPTIONS_KEY); boolean isExplicitlyDisabledByCapability = cap != null && "false".equalsIgnoreCase(cap.toString()); return propertySaysQuiet && !isExplicitlyDisabledByCapability; }
Example 2
Source File: GeckoDriverInfo.java From selenium with Apache License 2.0 | 5 votes |
@Override public boolean isSupporting(Capabilities capabilities) { if (capabilities.is(MARIONETTE)) { return false; } if (BrowserType.FIREFOX.equals(capabilities.getBrowserName())) { return true; } return capabilities.asMap().keySet().stream() .map(key -> key.startsWith("moz:")) .reduce(Boolean::logicalOr) .orElse(false); }
Example 3
Source File: GeckoDriverInfo.java From selenium with Apache License 2.0 | 5 votes |
@Override public Optional<WebDriver> createDriver(Capabilities capabilities) throws SessionNotCreatedException { if (!isAvailable()) { return Optional.empty(); } if (capabilities.is(MARIONETTE)) { return Optional.empty(); } return Optional.of(new FirefoxDriver(capabilities)); }
Example 4
Source File: XpiDriverInfo.java From selenium with Apache License 2.0 | 5 votes |
@Override public Optional<WebDriver> createDriver(Capabilities capabilities) throws SessionNotCreatedException { if (!isAvailable()) { return Optional.empty(); } if (!capabilities.is(MARIONETTE)) { return Optional.empty(); } return Optional.of(new FirefoxDriver(capabilities)); }
Example 5
Source File: RemoteWebDriver.java From selenium with Apache License 2.0 | 5 votes |
private void init(Capabilities capabilities) { capabilities = capabilities == null ? new ImmutableCapabilities() : capabilities; logger.addHandler(LoggingHandler.getInstance()); converter = new JsonToWebElementConverter(this); executeMethod = new RemoteExecuteMethod(this); keyboard = new RemoteKeyboard(executeMethod); mouse = new RemoteMouse(executeMethod); ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>(); boolean isProfilingEnabled = capabilities.is(CapabilityType.ENABLE_PROFILING_CAPABILITY); if (isProfilingEnabled) { builder.add(LogType.PROFILER); } LoggingPreferences mergedLoggingPrefs = new LoggingPreferences(); mergedLoggingPrefs.addPreferences((LoggingPreferences) capabilities.getCapability(LOGGING_PREFS)); if (!mergedLoggingPrefs.getEnabledLogTypes().contains(LogType.CLIENT) || mergedLoggingPrefs.getLevel(LogType.CLIENT) != Level.OFF) { builder.add(LogType.CLIENT); } Set<String> logTypesToInclude = builder.build(); LocalLogs performanceLogger = LocalLogs.getStoringLoggerInstance(logTypesToInclude); LocalLogs clientLogs = LocalLogs.getHandlerBasedLoggerInstance(LoggingHandler.getInstance(), logTypesToInclude); localLogs = LocalLogs.getCombinedLogsHolder(clientLogs, performanceLogger); remoteLogs = new RemoteLogs(executeMethod, localLogs); }
Example 6
Source File: TestClickAt.java From selenium with Apache License 2.0 | 5 votes |
private boolean isUsingNativeEvents() { if (!(selenium instanceof WrapsDriver)) { return false; } WebDriver driver = ((WrapsDriver) selenium).getWrappedDriver(); if (!(driver instanceof HasCapabilities)) { return false; } Capabilities capabilities = ((HasCapabilities) driver).getCapabilities(); return capabilities.is(CapabilityType.HAS_NATIVE_EVENTS); }
Example 7
Source File: CloudDescriptor.java From xframium-java with GNU General Public License v3.0 | 4 votes |
/** * Gets the cloud url. * * @return the cloud url */ public String getCloudUrl( Capabilities c ) { try { if ( provider != null && provider.name != null && provider.name.equals( "PERFECTO" ) ) { if ( getUserName() == null || getUserName().isEmpty() || getUserName().equals( "null") ) { if ( c.is( "perfectoFastWeb" ) ) return "https://" + getHostName() + "/nexperience/perfectomobile/wd/hub/fast"; else return "https://" + getHostName() + "/nexperience/perfectomobile/wd/hub"; } else { if ( c.is( "perfectoFastWeb" ) ) return "https://" + URLEncoder.encode( getUserName(), "UTF-8" ) + ":" + URLEncoder.encode( getPassword(), "UTF-8" ) + "@" + getHostName() + "/nexperience/perfectomobile/wd/hub/fast"; else return "https://" + URLEncoder.encode( getUserName(), "UTF-8" ) + ":" + URLEncoder.encode( getPassword(), "UTF-8" ) + "@" + getHostName() + "/nexperience/perfectomobile/wd/hub"; } } else if ( provider != null && provider.name != null && provider.name.equals( "BROWSERSTACK" ) ) return "https://" + URLEncoder.encode( getUserName(), "UTF-8" ) + ":" + URLEncoder.encode( getPassword(), "UTF-8" ) + "@" + getHostName() + "/wd/hub"; else if ( provider != null && provider.name != null && provider.name.equals( "SAUCELABS" ) ) return "http://" + URLEncoder.encode( getUserName(), "UTF-8" ) + ":" + URLEncoder.encode( getPassword(), "UTF-8" ) + "@" + getHostName() + "/wd/hub"; else if ( provider != null && provider.name != null && provider.name.equals( "WINDOWS" ) ) return "http://" + URLEncoder.encode( getUserName(), "UTF-8" ) + ":" + URLEncoder.encode( getPassword(), "UTF-8" ) + "@" + getHostName(); else { if ( getUserName() == null || getUserName().isEmpty() || getUserName().equals( "null") ) return "http://" + getHostName() + "/wd/hub"; else return "https://" + URLEncoder.encode( getUserName(), "UTF-8" ) + ":" + URLEncoder.encode( getPassword(), "UTF-8" ) + "@" + getHostName() + "/wd/hub"; } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
Example 8
Source File: XpiDriverInfo.java From selenium with Apache License 2.0 | 4 votes |
@Override public boolean isSupporting(Capabilities capabilities) { return capabilities.is(MARIONETTE); }
Example 9
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)); }