Jake Mosby
Jake Mosby

Reputation: 31

How can I follow DRY while implementing multi-browser coverage of UI automation?

I have a UI automation project built on C#, NUnit, and Playwright (for dotnet). My tests all currently inherit from ContextTest and leverage NUnit attributes including [TestCase] and [Retry]. I'm using ExtentReports to capture test results.

So far I've handled coverage of multiple browsers (need to cover edge, chrome, firefox, and safari/webkit) by creating four separate .runsettings files, one for each browser. To run the full test suite, I've got a powershell script that runs dotnet test --settings:<browser>.runsettings four times, once for each .runsettings file. ExtentReport then captures the result of each test+browser combination as a separate pass or fail.

But as I continue to add tests and update all my .runsettings, it's become clear that maintaining four such files breaks the "Don't Repeat Yourself" principle and I need to refactor. But I'm not sure how best to implement a more elegant solution to maintaining coverage for all my browsers.

I've explored using BrowserStack SDK to handle cross-platform considerations, but it didn't let NUnit's [Retry] accept a test's retried run result.

I've also looked into logic within each test that loops through the browsers, but this approach impacts the extent reports, marking a test as failed if it failed on any browser, rather than the more granular results of each test+browser combination getting its own record.

Upvotes: 1

Views: 22

Answers (0)

Related Questions