Skip to content

Commit

Permalink
[java] Adding getBrowserVersion to follow W3C, getVersion deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Sep 7, 2020
1 parent d6210d8 commit c3195c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions java/client/src/org/openqa/selenium/Capabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ default Platform getPlatform() {
.orElse(null);
}

/**
* @deprecated Use {@link #getBrowserVersion()}
*/
@Deprecated
default String getVersion() {
return getBrowserVersion();
}

default String getBrowserVersion() {
return String.valueOf(Optional.ofNullable(getCapability("browserVersion")).orElse(
Optional.ofNullable(getCapability("version")).orElse("")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected ChromiumDriver(CommandExecutor commandExecutor, Capabilities capabilit
getCapabilities(),
capabilityKey);

CdpInfo cdpInfo = new CdpVersionFinder().match(getCapabilities().getVersion())
CdpInfo cdpInfo = new CdpVersionFinder().match(getCapabilities().getBrowserVersion())
.orElseGet(() -> {
LOG.warning(
String.format(
Expand All @@ -122,7 +122,7 @@ protected ChromiumDriver(CommandExecutor commandExecutor, Capabilities capabilit
"version (\"v86\") matches the version of the chromium-based browser " +
"you're using and the version number of the artifact is the same " +
"as Selenium's.",
capabilities.getVersion(),
capabilities.getBrowserVersion(),
new BuildInfo().getReleaseLabel()));
return new NoOpCdpInfo();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* by...
* <ol>
* <li>{@link Capabilities#getBrowserName() browser name},
* <li>{@link Capabilities#getVersion() browser version},
* <li>{@link Capabilities#getBrowserVersion()} () browser version},
* <li>{@link Capabilities#is(String)} whether JavaScript is enabled},
* <li>and {@link Capabilities#getPlatform() platform}
* </ol>
Expand All @@ -60,9 +60,9 @@ public CapabilitiesComparator(final Capabilities desiredCapabilities,
Comparator.comparingInt(c -> browserNameScorer.score(c.getBrowserName()));

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

final CapabilityScorer<Boolean> jsScorer =
new CapabilityScorer<>(desiredCapabilities.is(SUPPORTS_JAVASCRIPT));
Expand Down

0 comments on commit c3195c3

Please sign in to comment.