17
17
18
18
package org .openqa .selenium .safari ;
19
19
20
+ import com .google .common .collect .ImmutableMap ;
21
+
22
+ import org .openqa .selenium .Beta ;
20
23
import org .openqa .selenium .Capabilities ;
21
24
import org .openqa .selenium .WebDriverException ;
22
25
import org .openqa .selenium .remote .FileDetector ;
23
26
import org .openqa .selenium .remote .RemoteWebDriver ;
24
- import org .openqa .selenium .remote .service . DriverCommandExecutor ;
27
+ import org .openqa .selenium .remote .Response ;
25
28
26
29
/**
27
30
* A WebDriver implementation that controls Safari using a browser extension
@@ -75,7 +78,7 @@ public SafariDriver(SafariDriverService safariService) {
75
78
* @param safariOptions safari specific options / capabilities for the driver
76
79
*/
77
80
public SafariDriver (SafariDriverService safariServer , SafariOptions safariOptions ) {
78
- super (new DriverCommandExecutor (safariServer ), safariOptions );
81
+ super (new SafariDriverCommandExecutor (safariServer ), safariOptions );
79
82
}
80
83
81
84
@ Override
@@ -84,4 +87,24 @@ public void setFileDetector(FileDetector detector) {
84
87
"Setting the file detector only works on remote webdriver instances obtained " +
85
88
"via RemoteWebDriver" );
86
89
}
90
+
91
+ /**
92
+ * Open either a new tab or window, depending on what is requested, and return the window handle
93
+ * without switching to it.
94
+ *
95
+ * @return The handle of the new window.
96
+ */
97
+ @ Beta
98
+ public String newWindow (WindowType type ) {
99
+ Response response = execute (
100
+ "SAFARI_NEW_WINDOW" ,
101
+ ImmutableMap .of ("newTab" , type == WindowType .TAB ));
102
+
103
+ return (String ) response .getValue ();
104
+ }
105
+
106
+ public enum WindowType {
107
+ TAB ,
108
+ WINDOW ,
109
+ }
87
110
}
0 commit comments