Skip to content

Commit f3a59a8

Browse files
committed
[java] updated logic in new getResult method for Driver Finder including validations
1 parent feed485 commit f3a59a8

23 files changed

+95
-32
lines changed

java/src/org/openqa/selenium/chrome/ChromeDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ private static ChromeDriverCommandExecutor generateExecutor(
9696
Require.nonNull("Driver service", service);
9797
Require.nonNull("Driver options", options);
9898
Require.nonNull("Driver clientConfig", clientConfig);
99-
Result result = DriverFinder.getPath(service, options);
99+
Result result = DriverFinder.getResult(service, options);
100100
service.setExecutable(result.getDriverPath());
101101
if (result.getBrowserPath() != null && !result.getBrowserPath().isEmpty()) {
102102
options.setBinary(result.getBrowserPath());
103+
options.setCapability("browserVersion", (Object) null);
103104
}
104105
return new ChromeDriverCommandExecutor(service, clientConfig);
105106
}

java/src/org/openqa/selenium/chrome/ChromeDriverInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public boolean isSupportingBiDi() {
6666
@Override
6767
public boolean isAvailable() {
6868
try {
69-
DriverFinder.getPath(ChromeDriverService.createDefaultService(), getCanonicalCapabilities());
69+
DriverFinder.getResult(ChromeDriverService.createDefaultService(), getCanonicalCapabilities());
7070
return true;
7171
} catch (NoSuchDriverException e) {
7272
return false;
@@ -79,7 +79,7 @@ public boolean isAvailable() {
7979
@Override
8080
public boolean isPresent() {
8181
try {
82-
DriverFinder.getPath(
82+
DriverFinder.getResult(
8383
ChromeDriverService.createDefaultService(), getCanonicalCapabilities(), true);
8484
return true;
8585
} catch (NoSuchDriverException e) {

java/src/org/openqa/selenium/chrome/ChromeDriverService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public Capabilities getDefaultDriverOptions() {
128128
/**
129129
* Configures and returns a new {@link ChromeDriverService} using the default configuration. In
130130
* this configuration, the service will use the ChromeDriver executable identified by {@link
131-
* org.openqa.selenium.remote.service.DriverFinder#getPath(DriverService, Capabilities)}. Each
131+
* org.openqa.selenium.remote.service.DriverFinder#getResult(DriverService, Capabilities)}. Each
132132
* service created by this method will be configured to use a free port on the current system.
133133
*
134134
* @return A new ChromeDriverService using the default configuration.

java/src/org/openqa/selenium/edge/EdgeDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ private static EdgeDriverCommandExecutor generateExecutor(
6868
Require.nonNull("Driver service", service);
6969
Require.nonNull("Driver options", options);
7070
Require.nonNull("Driver clientConfig", clientConfig);
71-
Result result = DriverFinder.getPath(service, options);
71+
Result result = DriverFinder.getResult(service, options);
7272
service.setExecutable(result.getDriverPath());
7373
if (result.getBrowserPath() != null && !result.getBrowserPath().isEmpty()) {
7474
options.setBinary(result.getBrowserPath());
75+
options.setCapability("browserVersion", (Object) null);
7576
}
7677
return new EdgeDriverCommandExecutor(service, clientConfig);
7778
}

java/src/org/openqa/selenium/edge/EdgeDriverInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public boolean isSupportingBiDi() {
6969
@Override
7070
public boolean isAvailable() {
7171
try {
72-
DriverFinder.getPath(EdgeDriverService.createDefaultService(), getCanonicalCapabilities());
72+
DriverFinder.getResult(EdgeDriverService.createDefaultService(), getCanonicalCapabilities());
7373
return true;
7474
} catch (NoSuchDriverException e) {
7575
return false;
@@ -82,7 +82,7 @@ public boolean isAvailable() {
8282
@Override
8383
public boolean isPresent() {
8484
try {
85-
DriverFinder.getPath(
85+
DriverFinder.getResult(
8686
EdgeDriverService.createDefaultService(), getCanonicalCapabilities(), true);
8787
return true;
8888
} catch (NoSuchDriverException e) {

java/src/org/openqa/selenium/edge/EdgeDriverService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public Capabilities getDefaultDriverOptions() {
117117
/**
118118
* Configures and returns a new {@link EdgeDriverService} using the default configuration. In this
119119
* configuration, the service will use the MSEdgeDriver executable identified by the {@link
120-
* org.openqa.selenium.remote.service.DriverFinder#getPath(DriverService, Capabilities)}. Each
120+
* org.openqa.selenium.remote.service.DriverFinder#getResult(DriverService, Capabilities)}. Each
121121
* service created by this method will be configured to use a free port on the current system.
122122
*
123123
* @return A new EdgeDriverService using the default configuration.

java/src/org/openqa/selenium/firefox/FirefoxDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ private static FirefoxDriverCommandExecutor generateExecutor(
138138
Require.nonNull("Driver service", service);
139139
Require.nonNull("Driver options", options);
140140
Require.nonNull("Driver clientConfig", clientConfig);
141-
Result result = DriverFinder.getPath(service, options);
141+
Result result = DriverFinder.getResult(service, options);
142142
service.setExecutable(result.getDriverPath());
143143
if (result.getBrowserPath() != null && !result.getBrowserPath().isEmpty()) {
144144
options.setBinary(result.getBrowserPath());
145+
options.setCapability("browserVersion", (Object) null);
145146
}
146147
return new FirefoxDriverCommandExecutor(service, clientConfig);
147148
}

java/src/org/openqa/selenium/firefox/GeckoDriverInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public boolean isSupportingBiDi() {
6969
@Override
7070
public boolean isAvailable() {
7171
try {
72-
DriverFinder.getPath(GeckoDriverService.createDefaultService(), getCanonicalCapabilities());
72+
DriverFinder.getResult(GeckoDriverService.createDefaultService(), getCanonicalCapabilities());
7373
return true;
7474
} catch (NoSuchDriverException e) {
7575
return false;
@@ -82,7 +82,7 @@ public boolean isAvailable() {
8282
@Override
8383
public boolean isPresent() {
8484
try {
85-
DriverFinder.getPath(
85+
DriverFinder.getResult(
8686
GeckoDriverService.createDefaultService(), getCanonicalCapabilities(), true);
8787
return true;
8888
} catch (NoSuchDriverException e) {

java/src/org/openqa/selenium/firefox/GeckoDriverService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public Capabilities getDefaultDriverOptions() {
110110
/**
111111
* Configures and returns a new {@link GeckoDriverService} using the default configuration. In
112112
* this configuration, the service will use the GeckoDriver executable identified by the {@link
113-
* org.openqa.selenium.remote.service.DriverFinder#getPath(DriverService, Capabilities)}. Each
113+
* org.openqa.selenium.remote.service.DriverFinder#getResult(DriverService, Capabilities)}. Each
114114
* service created by this method will be configured to use a free port on the current system.
115115
*
116116
* @return A new GeckoDriverService using the default configuration.

java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
131131
attributeMap.put(AttributeKey.LOGGER_CLASS.getKey(), this.getClass().getName());
132132

133133
DriverService service = builder.build();
134-
Result driverResult = DriverFinder.getPath(service, capabilities);
134+
Result driverResult = DriverFinder.getResult(service, capabilities);
135135
service.setExecutable(driverResult.getDriverPath());
136136
if (driverResult.getBrowserPath() != null && !driverResult.getBrowserPath().isEmpty()) {
137137
capabilities = setBrowserBinary(capabilities, driverResult.getBrowserPath());

0 commit comments

Comments
 (0)