36
36
import org .openqa .selenium .By ;
37
37
import org .openqa .selenium .WindowType ;
38
38
import org .openqa .selenium .bidi .module .LogInspector ;
39
+ import org .openqa .selenium .bidi .script .Source ;
39
40
import org .openqa .selenium .environment .webserver .AppServer ;
40
41
import org .openqa .selenium .environment .webserver .NettyAppServer ;
41
42
import org .openqa .selenium .testing .JupiterTestBase ;
@@ -62,9 +63,10 @@ void canListenToConsoleLog() throws ExecutionException, InterruptedException, Ti
62
63
driver .findElement (By .id ("consoleLog" )).click ();
63
64
64
65
ConsoleLogEntry logEntry = future .get (5 , TimeUnit .SECONDS );
65
-
66
+ Source source = logEntry .getSource ();
67
+ assertThat (source .getBrowsingContext ().isPresent ()).isTrue ();
68
+ assertThat (source .getRealm ()).isNotNull ();
66
69
assertThat (logEntry .getText ()).isEqualTo ("Hello, world!" );
67
- assertThat (logEntry .getRealm ()).isNull ();
68
70
assertThat (logEntry .getArgs ().size ()).isEqualTo (1 );
69
71
assertThat (logEntry .getArgs ().get (0 ).getType ()).isEqualTo ("string" );
70
72
assertThat (logEntry .getType ()).isEqualTo ("console" );
@@ -86,7 +88,6 @@ void canFilterConsoleLogs() throws ExecutionException, InterruptedException, Tim
86
88
ConsoleLogEntry logEntry = future .get (5 , TimeUnit .SECONDS );
87
89
88
90
assertThat (logEntry .getText ()).isEqualTo ("Hello, world!" );
89
- assertThat (logEntry .getRealm ()).isNull ();
90
91
assertThat (logEntry .getArgs ().size ()).isEqualTo (1 );
91
92
assertThat (logEntry .getType ()).isEqualTo ("console" );
92
93
assertThat (logEntry .getLevel ()).isEqualTo (LogLevel .INFO );
@@ -100,7 +101,6 @@ void canFilterConsoleLogs() throws ExecutionException, InterruptedException, Tim
100
101
ConsoleLogEntry errorLogEntry = errorLogfuture .get (5 , TimeUnit .SECONDS );
101
102
102
103
assertThat (errorLogEntry .getText ()).isEqualTo ("I am console error" );
103
- assertThat (errorLogEntry .getRealm ()).isNull ();
104
104
assertThat (errorLogEntry .getArgs ().size ()).isEqualTo (1 );
105
105
assertThat (errorLogEntry .getType ()).isEqualTo ("console" );
106
106
assertThat (errorLogEntry .getLevel ()).isEqualTo (LogLevel .ERROR );
@@ -123,6 +123,10 @@ void canListenToJavascriptLog()
123
123
124
124
JavascriptLogEntry logEntry = future .get (5 , TimeUnit .SECONDS );
125
125
126
+ Source source = logEntry .getSource ();
127
+ assertThat (source .getBrowsingContext ().isPresent ()).isTrue ();
128
+ assertThat (source .getRealm ()).isNotNull ();
129
+
126
130
assertThat (logEntry .getText ()).isEqualTo ("Error: Not working" );
127
131
assertThat (logEntry .getType ()).isEqualTo ("javascript" );
128
132
assertThat (logEntry .getLevel ()).isEqualTo (LogLevel .ERROR );
@@ -218,7 +222,6 @@ void canFilterLogs() throws ExecutionException, InterruptedException {
218
222
219
223
ConsoleLogEntry consoleLogEntry = logEntry .getConsoleLogEntry ().get ();
220
224
assertThat (consoleLogEntry .getText ()).isEqualTo ("Hello, world!" );
221
- assertThat (consoleLogEntry .getRealm ()).isNull ();
222
225
assertThat (consoleLogEntry .getArgs ().size ()).isEqualTo (1 );
223
226
assertThat (consoleLogEntry .getType ()).isEqualTo ("console" );
224
227
assertThat (consoleLogEntry .getLevel ()).isEqualTo (LogLevel .INFO );
@@ -243,7 +246,6 @@ void canListenToConsoleLogForABrowsingContext()
243
246
ConsoleLogEntry logEntry = future .get (5 , TimeUnit .SECONDS );
244
247
245
248
assertThat (logEntry .getText ()).isEqualTo ("Hello, world!" );
246
- assertThat (logEntry .getRealm ()).isNull ();
247
249
assertThat (logEntry .getArgs ().size ()).isEqualTo (1 );
248
250
assertThat (logEntry .getType ()).isEqualTo ("console" );
249
251
assertThat (logEntry .getLevel ()).isEqualTo (LogLevel .INFO );
0 commit comments