20
20
import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
21
21
import static org .assertj .core .api .AssertionsForClassTypes .assertThatExceptionOfType ;
22
22
import static org .openqa .selenium .testing .Safely .safelyCall ;
23
+ import static org .openqa .selenium .testing .drivers .Browser .CHROME ;
24
+ import static org .openqa .selenium .testing .drivers .Browser .EDGE ;
25
+ import static org .openqa .selenium .testing .drivers .Browser .IE ;
26
+ import static org .openqa .selenium .testing .drivers .Browser .SAFARI ;
23
27
24
28
import java .util .List ;
25
29
import org .junit .jupiter .api .AfterEach ;
26
30
import org .junit .jupiter .api .BeforeEach ;
27
31
import org .junit .jupiter .api .Test ;
28
- import org .junit .jupiter .api .extension .RegisterExtension ;
29
- import org .openqa .selenium .WebDriver ;
30
32
import org .openqa .selenium .WindowType ;
31
33
import org .openqa .selenium .bidi .BiDiException ;
32
34
import org .openqa .selenium .environment .webserver .AppServer ;
33
35
import org .openqa .selenium .environment .webserver .NettyAppServer ;
34
- import org .openqa .selenium .testing .NeedsFreshDriver ;
35
- import org .openqa .selenium .testing .SeleniumExtension ;
36
+ import org .openqa .selenium .testing .JupiterTestBase ;
37
+ import org .openqa .selenium .testing .NotYetImplemented ;
36
38
37
- class BrowsingContextTest {
39
+ class BrowsingContextTest extends JupiterTestBase {
38
40
39
- @ RegisterExtension static SeleniumExtension seleniumExtension = new SeleniumExtension ();
40
41
private AppServer server ;
41
- private WebDriver driver ;
42
42
43
43
@ BeforeEach
44
44
public void setUp () {
45
- driver = seleniumExtension .getDriver ();
46
-
47
45
server = new NettyAppServer ();
48
46
server .start ();
49
47
}
50
48
51
49
@ Test
50
+ @ NotYetImplemented (SAFARI )
51
+ @ NotYetImplemented (IE )
52
52
void canCreateABrowsingContextForGivenId () {
53
53
String id = driver .getWindowHandle ();
54
54
BrowsingContext browsingContext = new BrowsingContext (driver , id );
55
55
assertThat (browsingContext .getId ()).isEqualTo (id );
56
56
}
57
57
58
58
@ Test
59
+ @ NotYetImplemented (SAFARI )
60
+ @ NotYetImplemented (IE )
59
61
void canCreateAWindow () {
60
62
BrowsingContext browsingContext = new BrowsingContext (driver , WindowType .WINDOW );
61
63
assertThat (browsingContext .getId ()).isNotEmpty ();
62
64
}
63
65
64
66
@ Test
67
+ @ NotYetImplemented (SAFARI )
68
+ @ NotYetImplemented (IE )
69
+ @ NotYetImplemented (CHROME )
70
+ @ NotYetImplemented (EDGE )
65
71
void canCreateAWindowWithAReferenceContext () {
66
72
BrowsingContext browsingContext =
67
73
new BrowsingContext (driver , WindowType .WINDOW , driver .getWindowHandle ());
68
74
assertThat (browsingContext .getId ()).isNotEmpty ();
69
75
}
70
76
71
77
@ Test
78
+ @ NotYetImplemented (SAFARI )
79
+ @ NotYetImplemented (IE )
72
80
void canCreateATab () {
73
81
BrowsingContext browsingContext = new BrowsingContext (driver , WindowType .TAB );
74
82
assertThat (browsingContext .getId ()).isNotEmpty ();
75
83
}
76
84
77
85
@ Test
86
+ @ NotYetImplemented (SAFARI )
87
+ @ NotYetImplemented (IE )
88
+ @ NotYetImplemented (CHROME )
89
+ @ NotYetImplemented (EDGE )
78
90
void canCreateATabWithAReferenceContext () {
79
91
BrowsingContext browsingContext =
80
92
new BrowsingContext (driver , WindowType .TAB , driver .getWindowHandle ());
81
93
assertThat (browsingContext .getId ()).isNotEmpty ();
82
94
}
83
95
84
96
@ Test
97
+ @ NotYetImplemented (SAFARI )
98
+ @ NotYetImplemented (IE )
85
99
void canNavigateToAUrl () {
86
100
BrowsingContext browsingContext = new BrowsingContext (driver , WindowType .TAB );
87
101
88
102
String url = server .whereIs ("/bidi/logEntryAdded.html" );
89
103
NavigationResult info = browsingContext .navigate (url );
90
104
91
105
assertThat (browsingContext .getId ()).isNotEmpty ();
92
- assertThat (info .getNavigationId ()).isNull ();
93
106
assertThat (info .getUrl ()).contains ("/bidi/logEntryAdded.html" );
94
107
}
95
108
96
109
@ Test
110
+ @ NotYetImplemented (SAFARI )
111
+ @ NotYetImplemented (IE )
97
112
void canNavigateToAUrlWithReadinessState () {
98
113
BrowsingContext browsingContext = new BrowsingContext (driver , WindowType .TAB );
99
114
100
115
String url = server .whereIs ("/bidi/logEntryAdded.html" );
101
116
NavigationResult info = browsingContext .navigate (url , ReadinessState .COMPLETE );
102
117
103
118
assertThat (browsingContext .getId ()).isNotEmpty ();
104
- assertThat (info .getNavigationId ()).isNull ();
105
119
assertThat (info .getUrl ()).contains ("/bidi/logEntryAdded.html" );
106
120
}
107
121
108
122
@ Test
123
+ @ NotYetImplemented (SAFARI )
124
+ @ NotYetImplemented (IE )
125
+ @ NotYetImplemented (CHROME )
126
+ @ NotYetImplemented (EDGE )
109
127
void canGetTreeWithAChild () {
110
128
String referenceContextId = driver .getWindowHandle ();
111
129
BrowsingContext parentWindow = new BrowsingContext (driver , referenceContextId );
@@ -124,6 +142,10 @@ void canGetTreeWithAChild() {
124
142
}
125
143
126
144
@ Test
145
+ @ NotYetImplemented (SAFARI )
146
+ @ NotYetImplemented (IE )
147
+ @ NotYetImplemented (CHROME )
148
+ @ NotYetImplemented (EDGE )
127
149
void canGetTreeWithDepth () {
128
150
String referenceContextId = driver .getWindowHandle ();
129
151
BrowsingContext parentWindow = new BrowsingContext (driver , referenceContextId );
@@ -141,7 +163,8 @@ void canGetTreeWithDepth() {
141
163
}
142
164
143
165
@ Test
144
- @ NeedsFreshDriver
166
+ @ NotYetImplemented (SAFARI )
167
+ @ NotYetImplemented (IE )
145
168
void canGetAllTopLevelContexts () {
146
169
BrowsingContext window1 = new BrowsingContext (driver , driver .getWindowHandle ());
147
170
BrowsingContext window2 = new BrowsingContext (driver , WindowType .WINDOW );
@@ -152,6 +175,8 @@ void canGetAllTopLevelContexts() {
152
175
}
153
176
154
177
@ Test
178
+ @ NotYetImplemented (SAFARI )
179
+ @ NotYetImplemented (IE )
155
180
void canCloseAWindow () {
156
181
BrowsingContext window1 = new BrowsingContext (driver , WindowType .WINDOW );
157
182
BrowsingContext window2 = new BrowsingContext (driver , WindowType .WINDOW );
@@ -162,6 +187,8 @@ void canCloseAWindow() {
162
187
}
163
188
164
189
@ Test
190
+ @ NotYetImplemented (SAFARI )
191
+ @ NotYetImplemented (IE )
165
192
void canCloseATab () {
166
193
BrowsingContext tab1 = new BrowsingContext (driver , WindowType .TAB );
167
194
BrowsingContext tab2 = new BrowsingContext (driver , WindowType .TAB );
@@ -176,6 +203,9 @@ void canCloseATab() {
176
203
177
204
@ AfterEach
178
205
public void quitDriver () {
179
- safelyCall (seleniumExtension ::removeDriver , server ::stop );
206
+ if (driver != null ) {
207
+ driver .quit ();
208
+ }
209
+ safelyCall (server ::stop );
180
210
}
181
211
}
0 commit comments