37
37
*/
38
38
public class SafariDriver extends RemoteWebDriver {
39
39
40
- /**
41
- * Capability to force usage of the deprecated SafariDriver extension while running
42
- * on macOS Sierra.
43
- *
44
- * <pre>
45
- * DesiredCapabilities safariCap = DesiredCapabilities.Safari();
46
- * safariCap.setCapability(SafariDriver.USE_LEGACY_DRIVER_CAPABILITY, true);
47
- * WebDriver driver = new SafariDriver(safariCap);
48
- * </pre>
49
- */
50
- public static final String USE_LEGACY_DRIVER_CAPABILITY = "useLegacyDriver" ;
51
-
52
40
private SafariDriverService service ;
53
41
54
42
/**
@@ -82,23 +70,15 @@ public SafariDriver(SafariOptions safariOptions) {
82
70
* Ensure the new safaridriver receives non null required capabilities.
83
71
*/
84
72
private static Capabilities requiredCapabilities (SafariOptions options ) {
85
- if (isLegacy (options )) {
86
- return null ;
87
- }
88
73
return new DesiredCapabilities ();
89
74
}
90
75
91
76
private static CommandExecutor getExecutor (SafariOptions options ) {
92
77
SafariDriverService service = SafariDriverService .createDefaultService (options );
93
- if (isLegacy ( options ) && service ! = null ) {
94
- return new DriverCommandExecutor ( service );
78
+ if (service = = null ) {
79
+ throw new WebDriverException ( "SafariDriver requires Safari 10 running on OSX El Capitan or greater." );
95
80
}
96
- return new SafariDriverCommandExecutor (options );
97
- }
98
-
99
- private static boolean isLegacy (SafariOptions options ) {
100
- Object useLegacy = options .toCapabilities ().getCapability (USE_LEGACY_DRIVER_CAPABILITY );
101
- return useLegacy != null && (Boolean )useLegacy ;
81
+ return new DriverCommandExecutor (service );
102
82
}
103
83
104
84
@ Override
@@ -107,36 +87,4 @@ public void setFileDetector(FileDetector detector) {
107
87
"Setting the file detector only works on remote webdriver instances obtained " +
108
88
"via RemoteWebDriver" );
109
89
}
110
-
111
- @ Override
112
- protected void startClient () {
113
- CommandExecutor commandExecutor = this .getCommandExecutor ();
114
- if (commandExecutor instanceof SafariDriverCommandExecutor ) {
115
- try {
116
- ((SafariDriverCommandExecutor )commandExecutor ).start ();
117
- } catch (IOException e ) {
118
- throw new WebDriverException (e );
119
- }
120
- } else {
121
- super .startClient ();
122
- }
123
- }
124
-
125
- @ Override
126
- protected void stopClient () {
127
- CommandExecutor commandExecutor = this .getCommandExecutor ();
128
- if (commandExecutor instanceof SafariDriverCommandExecutor ) {
129
- ((SafariDriverCommandExecutor )commandExecutor ).stop ();
130
- } else {
131
- super .stopClient ();
132
- }
133
- }
134
-
135
- @ Override
136
- public <X > X getScreenshotAs (OutputType <X > target ) throws WebDriverException {
137
- // Get the screenshot as base64.
138
- String base64 = (String ) execute (DriverCommand .SCREENSHOT ).getValue ();
139
- // ... and convert it.
140
- return target .convertFromBase64Png (base64 );
141
- }
142
90
}
0 commit comments