-
Notifications
You must be signed in to change notification settings - Fork 249
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
[Feature]: Load Playwright settings programmatically as an alternative to a .runsettings
file
#3081
Comments
As an alternative to using a .runsettings XML file. Fixes microsoft#3081
As an alternative to using a .runsettings XML file. Fixes microsoft#3081
As an alternative to using a .runsettings XML file. Fixes microsoft#3081
We intentionally had these settings configured on a global level before - this would require us to diverge from what we do in Node.js or Python. Usually for end-to-end tests, you write a test once and run them on all the browsers. For that you run |
Hi @0xced, if it helps with what you need, I usually prefer to have a JSON configuration file and define my browser options in there under different profiles, then I just deserialise as needed and pass that object to the browser on initialisation. The profile is selected by name by an environment variable of sorts, so it can be dynamically set, e.g. .runsettings, CLI command argument, or pipeline variable. Some of the reasons for which I prefer this method are that 1) it keeps the config out of the code, which is what I believe that the official .runsettings approach is aiming for, but 2) is more powerful, flexible, reusable, and transparent than .runsetting config. |
As an alternative to using a .runsettings XML file. Fixes microsoft#3081
🚀 Feature Request
Currently, setting the
BrowserTypeLaunchOptions
when running tests with theMicrosoft.Playwright.MSTest
,Microsoft.Playwright.NUnit
orMicrosoft.Playwright.Xunit
pacakge is controlled through the .runsettings configuration file.It would be nice to be able to control the launch options programmatically, just like
BrowserNewContextOptions
can be controlled programmatically by overriding theContextOptions()
method.Example
This example is given with Xunit but would work the same with MSTest or NUnit.
Motivation
Controlling options programatically opens up new possibilities that are not achievable with a
.runsettings
file. For example, one could decide to run tests on Firefox based on some runtime conditions or change the value of theTimeout
based on what hardware the tests are running on. This would give a lot of power to Playwright users.Also, having a new
PlaywrightSettings
type is great for discoverability. Typing properties with autocompletion support from your IDE is a much better experience than writing XML elements in a.runsettings
file without any autocompletion.Finally,
.runsettings
support in Rider is pretty broken, I was not able to get theMicrosoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ISettingsProvider.Load
method to be called, rendring Playwright.runsettings
unusable with Rider. See alsoTestCaseFilter
in.runsettings
ignored.The text was updated successfully, but these errors were encountered: