Repository navigation
Start Chrome and Firefox once before the first test that uses them - #28
Draft
jwrosewell wants to merge 2 commits into
Draft
jwrosewell wants to merge 2 commits into
jwrosewell wants to merge 2 commits into
Conversation
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A browser's first start in a run of this suite can take far longer than the starts after it, and while it does, the first test that uses the browser spends its own time on it. The Selenium .NET client gives each command 60 seconds, so a slow first start can fail a test that has nothing wrong with it.
Example_RendersRealDetectionResultfailed with "session not created from disconnected: unable to connect to renderer" fromnew ChromeDriverinHelpers/BrowserDrivers.csline 130.Example_RendersClientSideOverridesOnThePagefailed with "Driver service process exited unexpectedly before initialization completed".Each language worked round this in its own CI, by starting the browser once before the suite runs (51degrees-java#124, 51degrees-rust#416, 51degrees-dotnet#207 for .NET's own browser tests). Doing it here gives every language's run of this suite the same, through the driver the suite itself uses.
What changed
BrowserDrivers.StartOnceruns a browser's first start the first time the browser is asked for in a run, and never again. The start creates the driver with a limit of 300 seconds for each command (FirstStartTimeoutSeconds), loadsabout:blankand quits. It writes "Started Chrome once before its first test in N s." to the output of the test that asked. Whatever stops the start is written with the first line of its reason and is not thrown, so the test then starts the browser as it would have and meets any real fault itself.CreateChromeandCreateFirefoxcall it before they create the test's driver, with the same driver, binary and options, whether the machine provides the driver or Selenium Manager fetches it. A remote Selenium (SELENIUM_URL) is not started first, because a grid keeps its browsers running.Edge_RunsThePageis ignored), which would hold the run for the full 300 seconds. NoContracttest uses Edge.FirstStartsgives the line written for each browser, for the tests.README.mdsays so under "How a run is wired".Tests
New
Selenium/FirstStartTests.cs. They reachStartOnce,FirstStartsandFirstStartTimeoutSecondsby name, so that onrcthey fail when they run rather than stopping the build.StartOnce_StartsEachBrowserOnceandStartOnce_AStartThatFails_IsReportedAndNotThrownuse a stand-in start and need no browser, so they run in this repository's first CI job. A browser asked for twice is started once and given the 300 second limit, and a start that throws is written, not thrown, and not tried again.Chrome_StartsOnceBeforeItsFirstTestandFirefox_StartsOnceBeforeItsFirstTest, in theBrowsercategory, create the browser twice, load a page each time and check the first start was made. They write how long each of the two took.Both runs used a temporary branch holding the commits and one workflow that builds the suite and runs these tests and
DriverSmokeTestson ubuntu-latest, ubuntu-22.04, ubuntu-22.04-arm and windows-latest. The branches are deleted.rc. On each of the four runners the four new tests failed ("BrowserDrivers has no StartOnce" and "has no FirstStarts") and the two smoke tests passed.Edge_RunsThePagewas skipped as it always is.The times the green run wrote, in seconds:
"Then" is a later start of the same browser with a page loaded, as a test makes it. So in this run every first start took longer than the starts after it, by up to 18 seconds, and none came near 60 seconds. The longer first starts recorded in the other repositories did not happen here, and this run shows only that the first start is now made before the first test and timed.
Build
This repository's own checks on this pull request build the suite, run the tests that need no browser, and start Chrome and Firefox on its three Ubuntu runners.
What remains
main, so the change reaches them whenrcis released intomain.mainholds the two release commits of 11 November thatrcdoes not, somainis merged back intorcfirst.