Skip to content

Commit 476dc6b

Browse files
committed
[java][bidi] Refine filtering logs test
1 parent 26dd4de commit 476dc6b

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

java/test/org/openqa/selenium/bidi/LogInspectorTest.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void canListenToConsoleLog() throws ExecutionException, InterruptedException, Ti
8787
}
8888

8989
@Test
90-
void canFilterConsoleLogs() throws ExecutionException, InterruptedException {
90+
void canFilterConsoleLogs() throws ExecutionException, InterruptedException, TimeoutException {
9191
try (LogInspector logInspector = new LogInspector(driver)) {
9292
CompletableFuture<ConsoleLogEntry> future = new CompletableFuture<>();
9393
logInspector.onConsoleEntry(future::complete, FilterBy.logLevel(LogLevel.INFO));
@@ -96,12 +96,7 @@ void canFilterConsoleLogs() throws ExecutionException, InterruptedException {
9696
driver.get(page);
9797
driver.findElement(By.id("consoleLog")).click();
9898

99-
ConsoleLogEntry logEntry = null;
100-
try {
101-
logEntry = future.get(5, TimeUnit.SECONDS);
102-
} catch (TimeoutException e) {
103-
fail("Time out exception" + e.getMessage());
104-
}
99+
ConsoleLogEntry logEntry = future.get(5, TimeUnit.SECONDS);
105100

106101
assertThat(logEntry.getText()).isEqualTo("Hello, world!");
107102
assertThat(logEntry.getRealm()).isNull();
@@ -113,11 +108,19 @@ void canFilterConsoleLogs() throws ExecutionException, InterruptedException {
113108

114109
CompletableFuture<ConsoleLogEntry> errorLogfuture = new CompletableFuture<>();
115110

116-
logInspector.onConsoleEntry(errorLogfuture::complete, FilterBy.logLevel(LogLevel.WARNING));
117-
driver.findElement(By.id("consoleLog")).click();
111+
logInspector.onConsoleEntry(errorLogfuture::complete, FilterBy.logLevel(LogLevel.ERROR));
112+
driver.findElement(By.id("consoleError")).click();
118113

119-
assertThatExceptionOfType(TimeoutException.class).isThrownBy(
120-
() -> errorLogfuture.get(5, TimeUnit.SECONDS));
114+
ConsoleLogEntry errorLogEntry = errorLogfuture.get(5, TimeUnit.SECONDS);
115+
116+
assertThat(errorLogEntry.getText()).isEqualTo("I am console error");
117+
assertThat(errorLogEntry.getRealm()).isNull();
118+
assertThat(errorLogEntry.getArgs().size()).isEqualTo(1);
119+
assertThat(errorLogEntry.getType()).isEqualTo("console");
120+
assertThat(errorLogEntry.getLevel()).isEqualTo(LogLevel.ERROR);
121+
assertThat(errorLogEntry.getMethod()).isEqualTo("error");
122+
assertThat(errorLogEntry.getStackTrace()).isNotNull();
123+
assertThat(errorLogEntry.getStackTrace().getCallFrames().size()).isEqualTo(2);
121124
}
122125
}
123126

0 commit comments

Comments
 (0)