20
20
import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
21
21
import static org .assertj .core .api .AssertionsForClassTypes .assertThatExceptionOfType ;
22
22
23
- import java .util .Collections ;
24
23
import org .junit .jupiter .api .Test ;
25
24
import org .openqa .selenium .WebDriverException ;
26
25
import org .openqa .selenium .WindowType ;
@@ -42,8 +41,7 @@ void shouldNotCloseBiDiSessionIfOneWindowIsClosed() {
42
41
43
42
BiDi biDi = driver .getBiDi ();
44
43
45
- BiDiSessionStatus status =
46
- biDi .send (new Command <>("session.status" , Collections .emptyMap (), BiDiSessionStatus .class ));
44
+ BiDiSessionStatus status = biDi .getBidiSessionStatus ();
47
45
assertThat (status ).isNotNull ();
48
46
assertThat (status .getMessage ()).isEqualTo ("Session already started" );
49
47
@@ -53,8 +51,7 @@ void shouldNotCloseBiDiSessionIfOneWindowIsClosed() {
53
51
54
52
driver .close ();
55
53
56
- BiDiSessionStatus statusAfterClosing =
57
- biDi .send (new Command <>("session.status" , Collections .emptyMap (), BiDiSessionStatus .class ));
54
+ BiDiSessionStatus statusAfterClosing = biDi .getBidiSessionStatus ();
58
55
assertThat (statusAfterClosing ).isNotNull ();
59
56
assertThat (status .getMessage ()).isEqualTo ("Session already started" );
60
57
driver .quit ();
@@ -70,19 +67,14 @@ void shouldCloseBiDiSessionIfLastWindowIsClosed() {
70
67
71
68
BiDi biDi = driver .getBiDi ();
72
69
73
- BiDiSessionStatus status =
74
- biDi .send (new Command <>("session.status" , Collections .emptyMap (), BiDiSessionStatus .class ));
70
+ BiDiSessionStatus status = biDi .getBidiSessionStatus ();
75
71
assertThat (status ).isNotNull ();
76
72
assertThat (status .getMessage ()).isEqualTo ("Session already started" );
77
73
78
74
driver .close ();
79
75
80
76
// Closing the last top-level browsing context, closes the WebDriver and BiDi session
81
77
assertThatExceptionOfType (WebDriverException .class )
82
- .isThrownBy (
83
- () ->
84
- biDi .send (
85
- new Command <>(
86
- "session.status" , Collections .emptyMap (), BiDiSessionStatus .class )));
78
+ .isThrownBy (() -> biDi .getBidiSessionStatus ());
87
79
}
88
80
}
0 commit comments