microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

[Question]: Accessing Browser Options In MSTest #2148

Closed mindingdata closed 2 years ago

mindingdata commented 2 years ago

Your question

I am trying to use Playwright with MSTest (Mostly so that the Setup/Teardown is done for me). But I'm trying to understand how I can configure the browser to run in headless/non-headless on demand (e.g. If a test is breaking, I want to be able to see what it's trying to do or where it is at that time).

What I've found is this piece of code here :

https://github.com/microsoft/playwright-dotnet/blob/7610aa52550afa06c9ce68958fc432ced528c740/src/Playwright.MSTest/Services/BrowserService.cs#L42

That essentially is reading an Environment variable to specify whether the browser is headless or not. Is this the only way to configure this when using MSTest? Switching between Environment Variables?

mindingdata commented 2 years ago

While it doesn't directly address my question, you can atleast manipulate these for your tests by using RunSettings files (https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022#specify-environment-variables-in-the-runsettings-file).

I believe these still only work inside Visual Studio (Not sure on VSCode) and not in any other environment.

mxschmitt commented 2 years ago

In the next version we'll ship two new features: a) customize launch options via runsettings b customize context settings via the method override

See here for the docs, it gets released in around a week: https://playwright.dev/dotnet/docs/next/test-runners#mstest

Closing it in the meantime and sorry for the late reply! For further questions/feature requests please file new issues.