Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Selenium to 4.16.1 #386

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ext {
core = project(':core')
report = project(':report-ng')

seleniumVersion = '4.14.1'
seleniumVersion = '4.16.1'
// Must be the same like in Selenium 4
guavaVersion = "32.1.2-jre"

Expand Down
31 changes: 20 additions & 11 deletions docs/src/docs/selenium4/selenium4-webdriver-bidi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The browser console window shows different types of logging information. You hav
IMPORTANT: The created consumer for all listeners will be executed in an additional thread. +
If you use an `Assert` this will be no impact to the main thread.

.Example for listening to simple console logs
.Example for listening to all console logs
[source, java]
----

Expand Down Expand Up @@ -50,27 +50,36 @@ public class WebDriverBiDiTests extends TesterraTest implements
LogInspector logInspector = new LogInspector(remoteDriver);

// Look for the type of log entries you want to catch
List<ConsoleLogEntry> logEntryList = new ArrayList<>();
List<LogEntry> logEntryList = new ArrayList<>();
logInspector.onConsoleEntry(logEntryList::add);

uiElementFinder.find(By.id("consoleLog")).click();
uiElementFinder.find(By.id("consoleError")).click();
uiElementFinder.find(By.id("jsException")).click();
uiElementFinder.find(By.id("logWithStacktrace")).click();

// To make sure we have at least 4 elements in our list
CONTROL.retryTimes(5, () -> {
ASSERT.assertTrue(logEntryList.size() > 1);
ASSERT.assertTrue(logEntryList.size() >= 4);
TimerUtils.sleepSilent(1000);
});

logEntryList.forEach(logEntry ->
log().info(
"LOG_ENTRY: {} {} {} - {}",
logEntry.getTimestamp(),
logEntry.getLevel(),
logEntry.getMethod(),
logEntry.getText())
logEntryList.forEach(logEntry -> {
AtomicReference<GenericLogEntry> genericLogEntry = new AtomicReference<>();
// 'LogEntry' is only a container for different types of logs.
logEntry.getConsoleLogEntry().ifPresent(genericLogEntry::set);
logEntry.getJavascriptLogEntry().ifPresent(genericLogEntry::set);

log().info("LOG_ENTRY: {} {} {} {} - {}",
genericLogEntry.get().getTimestamp(),
genericLogEntry.get().getType(),
genericLogEntry.get().getLevel(),
genericLogEntry.get().getType(),
genericLogEntry.get().getText()
);
});

ASSERT.assertEquals(logEntryList.size(), 2, "LogEntry list");
ASSERT.assertEquals(logEntryList.size(), 4, "LogEntry list");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.bidi.LogInspector;
import org.openqa.selenium.bidi.log.ConsoleLogEntry;
import org.openqa.selenium.bidi.log.GenericLogEntry;
import org.openqa.selenium.bidi.log.JavascriptLogEntry;
import org.openqa.selenium.bidi.log.LogEntry;
import org.openqa.selenium.chrome.ChromeDriver;
Expand All @@ -44,6 +45,7 @@
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
* Created on 2023-06-22
Expand Down Expand Up @@ -172,6 +174,21 @@ public void testT03_LogListener_AllLogs() throws MalformedURLException {
});

ASSERT.assertEquals(logEntryList.size(), 4, "LogEntry list");

logEntryList.forEach(logEntry -> {
AtomicReference<GenericLogEntry> genericLogEntry = new AtomicReference<>();
logEntry.getConsoleLogEntry().ifPresent(genericLogEntry::set);
logEntry.getJavascriptLogEntry().ifPresent(genericLogEntry::set);

log().info("LOG_ENTRY: {} {} {} {} - {}",
genericLogEntry.get().getTimestamp(),
genericLogEntry.get().getType(),
genericLogEntry.get().getLevel(),
genericLogEntry.get().getType(),
genericLogEntry.get().getText()
);
});

}


Expand Down