Reputation: 31
Is there any way for us to just change the runsettings file for Cross Browser Testing in Playwright with dotnet (any Test Runner)? I want each test to run in multiple browsers, so that each test is independent of the other and also I accomplish CBT
CBT should work as expected
Upvotes: 1
Views: 127
Reputation: 3936
There are various ways to achieve this
You can do this via command line by passing a different runsettings file every time
dotnet test --settings:chromium.runsettings
dotnet test --settings:firefox.runsettings
dotnet test --settings:webkit.runsettings
You can pass like this too if you want to maintain a single runsettings file
dotnet test -- Playwright.BrowserName=webkit
You can place a variable in runsettings file, which you can pass from pipeline which would be changed dynamically at runtime
<browser>#{BROWSER}#</browser>
You can also control stuff if you are initializing your Context on your own in below line by reading the value of browser from pipeline
If(browser == Chrome)
{
await using var browser = await playwright.Chromium.LaunchAsync();
}
else if (other browser)
Also to save resources you can do 1 thing based on time of the day or a particular day, run your test in a particular browser.
if its Monday then chrome if Tuesday then edge instead of running all browsers all the time
Upvotes: 0