2020import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
2121import static org .assertj .core .api .AssertionsForClassTypes .assertThatExceptionOfType ;
2222import 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 ;
2327
2428import java .util .List ;
2529import org .junit .jupiter .api .AfterEach ;
2630import org .junit .jupiter .api .BeforeEach ;
2731import org .junit .jupiter .api .Test ;
28- import org .junit .jupiter .api .extension .RegisterExtension ;
29- import org .openqa .selenium .WebDriver ;
3032import org .openqa .selenium .WindowType ;
3133import org .openqa .selenium .bidi .BiDiException ;
3234import org .openqa .selenium .environment .webserver .AppServer ;
3335import 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 ;
3638
37- class BrowsingContextTest {
39+ class BrowsingContextTest extends JupiterTestBase {
3840
39- @ RegisterExtension static SeleniumExtension seleniumExtension = new SeleniumExtension ();
4041 private AppServer server ;
41- private WebDriver driver ;
4242
4343 @ BeforeEach
4444 public void setUp () {
45- driver = seleniumExtension .getDriver ();
46-
4745 server = new NettyAppServer ();
4846 server .start ();
4947 }
5048
5149 @ Test
50+ @ NotYetImplemented (SAFARI )
51+ @ NotYetImplemented (IE )
5252 void canCreateABrowsingContextForGivenId () {
5353 String id = driver .getWindowHandle ();
5454 BrowsingContext browsingContext = new BrowsingContext (driver , id );
5555 assertThat (browsingContext .getId ()).isEqualTo (id );
5656 }
5757
5858 @ Test
59+ @ NotYetImplemented (SAFARI )
60+ @ NotYetImplemented (IE )
5961 void canCreateAWindow () {
6062 BrowsingContext browsingContext = new BrowsingContext (driver , WindowType .WINDOW );
6163 assertThat (browsingContext .getId ()).isNotEmpty ();
6264 }
6365
6466 @ Test
67+ @ NotYetImplemented (SAFARI )
68+ @ NotYetImplemented (IE )
69+ @ NotYetImplemented (CHROME )
70+ @ NotYetImplemented (EDGE )
6571 void canCreateAWindowWithAReferenceContext () {
6672 BrowsingContext browsingContext =
6773 new BrowsingContext (driver , WindowType .WINDOW , driver .getWindowHandle ());
6874 assertThat (browsingContext .getId ()).isNotEmpty ();
6975 }
7076
7177 @ Test
78+ @ NotYetImplemented (SAFARI )
79+ @ NotYetImplemented (IE )
7280 void canCreateATab () {
7381 BrowsingContext browsingContext = new BrowsingContext (driver , WindowType .TAB );
7482 assertThat (browsingContext .getId ()).isNotEmpty ();
7583 }
7684
7785 @ Test
86+ @ NotYetImplemented (SAFARI )
87+ @ NotYetImplemented (IE )
88+ @ NotYetImplemented (CHROME )
89+ @ NotYetImplemented (EDGE )
7890 void canCreateATabWithAReferenceContext () {
7991 BrowsingContext browsingContext =
8092 new BrowsingContext (driver , WindowType .TAB , driver .getWindowHandle ());
8193 assertThat (browsingContext .getId ()).isNotEmpty ();
8294 }
8395
8496 @ Test
97+ @ NotYetImplemented (SAFARI )
98+ @ NotYetImplemented (IE )
8599 void canNavigateToAUrl () {
86100 BrowsingContext browsingContext = new BrowsingContext (driver , WindowType .TAB );
87101
88102 String url = server .whereIs ("/bidi/logEntryAdded.html" );
89103 NavigationResult info = browsingContext .navigate (url );
90104
91105 assertThat (browsingContext .getId ()).isNotEmpty ();
92- assertThat (info .getNavigationId ()).isNull ();
93106 assertThat (info .getUrl ()).contains ("/bidi/logEntryAdded.html" );
94107 }
95108
96109 @ Test
110+ @ NotYetImplemented (SAFARI )
111+ @ NotYetImplemented (IE )
97112 void canNavigateToAUrlWithReadinessState () {
98113 BrowsingContext browsingContext = new BrowsingContext (driver , WindowType .TAB );
99114
100115 String url = server .whereIs ("/bidi/logEntryAdded.html" );
101116 NavigationResult info = browsingContext .navigate (url , ReadinessState .COMPLETE );
102117
103118 assertThat (browsingContext .getId ()).isNotEmpty ();
104- assertThat (info .getNavigationId ()).isNull ();
105119 assertThat (info .getUrl ()).contains ("/bidi/logEntryAdded.html" );
106120 }
107121
108122 @ Test
123+ @ NotYetImplemented (SAFARI )
124+ @ NotYetImplemented (IE )
125+ @ NotYetImplemented (CHROME )
126+ @ NotYetImplemented (EDGE )
109127 void canGetTreeWithAChild () {
110128 String referenceContextId = driver .getWindowHandle ();
111129 BrowsingContext parentWindow = new BrowsingContext (driver , referenceContextId );
@@ -124,6 +142,10 @@ void canGetTreeWithAChild() {
124142 }
125143
126144 @ Test
145+ @ NotYetImplemented (SAFARI )
146+ @ NotYetImplemented (IE )
147+ @ NotYetImplemented (CHROME )
148+ @ NotYetImplemented (EDGE )
127149 void canGetTreeWithDepth () {
128150 String referenceContextId = driver .getWindowHandle ();
129151 BrowsingContext parentWindow = new BrowsingContext (driver , referenceContextId );
@@ -141,7 +163,8 @@ void canGetTreeWithDepth() {
141163 }
142164
143165 @ Test
144- @ NeedsFreshDriver
166+ @ NotYetImplemented (SAFARI )
167+ @ NotYetImplemented (IE )
145168 void canGetAllTopLevelContexts () {
146169 BrowsingContext window1 = new BrowsingContext (driver , driver .getWindowHandle ());
147170 BrowsingContext window2 = new BrowsingContext (driver , WindowType .WINDOW );
@@ -152,6 +175,8 @@ void canGetAllTopLevelContexts() {
152175 }
153176
154177 @ Test
178+ @ NotYetImplemented (SAFARI )
179+ @ NotYetImplemented (IE )
155180 void canCloseAWindow () {
156181 BrowsingContext window1 = new BrowsingContext (driver , WindowType .WINDOW );
157182 BrowsingContext window2 = new BrowsingContext (driver , WindowType .WINDOW );
@@ -162,6 +187,8 @@ void canCloseAWindow() {
162187 }
163188
164189 @ Test
190+ @ NotYetImplemented (SAFARI )
191+ @ NotYetImplemented (IE )
165192 void canCloseATab () {
166193 BrowsingContext tab1 = new BrowsingContext (driver , WindowType .TAB );
167194 BrowsingContext tab2 = new BrowsingContext (driver , WindowType .TAB );
@@ -176,6 +203,9 @@ void canCloseATab() {
176203
177204 @ AfterEach
178205 public void quitDriver () {
179- safelyCall (seleniumExtension ::removeDriver , server ::stop );
206+ if (driver != null ) {
207+ driver .quit ();
208+ }
209+ safelyCall (server ::stop );
180210 }
181211}
0 commit comments