File tree 2 files changed +31
-3
lines changed
java/client/src/org/openqa/selenium/safari
2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -75,18 +75,32 @@ public SafariDriver(Capabilities desiredCapabilities) {
75
75
* @param safariOptions safari specific options / capabilities for the driver
76
76
*/
77
77
public SafariDriver (SafariOptions safariOptions ) {
78
- super (getExecutor (safariOptions ), safariOptions .toCapabilities ());
78
+ super (getExecutor (safariOptions ), safariOptions .toCapabilities (), requiredCapabilities (safariOptions ));
79
+ }
80
+
81
+ /**
82
+ * Ensure the new safaridriver receives non null required capabilities.
83
+ */
84
+ private static Capabilities requiredCapabilities (SafariOptions options ) {
85
+ if (isLegacy (options )) {
86
+ return null ;
87
+ }
88
+ return new DesiredCapabilities ();
79
89
}
80
90
81
91
private static CommandExecutor getExecutor (SafariOptions options ) {
82
- Object useLegacy = options .toCapabilities ().getCapability (USE_LEGACY_DRIVER_CAPABILITY );
83
92
SafariDriverService service = SafariDriverService .createDefaultService (options );
84
- if (( useLegacy == null || !( Boolean ) useLegacy ) && service != null ) {
93
+ if (isLegacy ( options ) && service != null ) {
85
94
return new DriverCommandExecutor (service );
86
95
}
87
96
return new SafariDriverCommandExecutor (options );
88
97
}
89
98
99
+ private static boolean isLegacy (SafariOptions options ) {
100
+ Object useLegacy = options .toCapabilities ().getCapability (USE_LEGACY_DRIVER_CAPABILITY );
101
+ return useLegacy != null && (Boolean )useLegacy ;
102
+ }
103
+
90
104
@ Override
91
105
public void setFileDetector (FileDetector detector ) {
92
106
throw new WebDriverException (
Original file line number Diff line number Diff line change 17
17
18
18
package org .openqa .selenium .safari ;
19
19
20
+ import static java .util .concurrent .TimeUnit .SECONDS ;
21
+
20
22
import com .google .common .collect .ImmutableList ;
21
23
import com .google .common .collect .ImmutableMap ;
22
24
23
25
import org .openqa .selenium .WebDriverException ;
26
+ import org .openqa .selenium .net .PortProber ;
24
27
import org .openqa .selenium .remote .service .DriverService ;
25
28
26
29
import java .io .File ;
27
30
import java .io .IOException ;
31
+ import java .net .MalformedURLException ;
32
+ import java .util .concurrent .ExecutionException ;
28
33
29
34
public class SafariDriverService extends DriverService {
30
35
@@ -42,6 +47,15 @@ public static SafariDriverService createDefaultService(SafariOptions options) {
42
47
return null ;
43
48
}
44
49
50
+ @ Override
51
+ protected void waitUntilAvailable () throws MalformedURLException {
52
+ try {
53
+ PortProber .waitForPortUp (getUrl ().getPort (), 20 , SECONDS );
54
+ } catch (Exception e ) {
55
+ e .printStackTrace ();
56
+ }
57
+ }
58
+
45
59
public static class Builder extends DriverService .Builder <
46
60
SafariDriverService , SafariDriverService .Builder > {
47
61
You can’t perform that action at this time.
0 commit comments