-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Open
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!C-dotnet.NET Bindings.NET BindingsD-chromeI-defectSomething is not working as intendedSomething is not working as intendedOS-windows
Description
Description
It appears that not all console logs are sent over the BiDi web socket and there is some kind of race condition when closing down the connection.
If I want to make sure that I receive all the log entries before the browser closes, it appears that I need to add a time based delay, which results in flaky and/or slow tests.
I've attached a simple example that demonstrates the logs are not send to OnEntryAddedAsync unless I add a time-based delay.
Am I doing something wrong here?
Reproducible Code
// <PackageReference Include="Selenium.WebDriver" Version="4.38.0" />
using System.Collections.Concurrent;
using OpenQA.Selenium.BiDi;
using OpenQA.Selenium.Chrome;
var options = new ChromeOptions { UseWebSocketUrl = true };
using var driver = new ChromeDriver(options);
await using var biDi = await driver.AsBiDiAsync();
var logs = new ConcurrentBag<string?>();
await using var logSubscription = await biDi.Log.OnEntryAddedAsync(entry => logs.Add(entry.Text));
driver.Navigate().GoToUrl("about:blank");
driver.ExecuteScript("console.log('Test log.');");
//Uncommenting this line will "fix" the issue.
//await Task.Delay(1000);
if(!logs.SequenceEqual(["Test log."]))
throw new Exception("Logs missing.");
Console.WriteLine("Logs present.");Metadata
Metadata
Assignees
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!C-dotnet.NET Bindings.NET BindingsD-chromeI-defectSomething is not working as intendedSomething is not working as intendedOS-windows