0

I started using Playwright in MSTest and I have my test class implement the base PageTest class.

One thing I am wondering: Is the instance of the injected Page object gets reset on every TestMethod?

I tried to log the Page.URL on every TestMethod and the first one got it correctly (set via the overridden ContextOptions) but the succeeding logs shows null. And when I took a screenshot inside the TestMethods, the first one shows my full page but the next ones are empty.

Is this expected behavior? Does it mean I have to visit and login again on the site I am testing on every TestMethods that I have?

I am coming from Cypress and each test function inside the spec file shares the same context of the page. So I am wondering if I setup something wrong or is this expected behavior.

raberana
  • 11,739
  • 18
  • 69
  • 95
  • https://playwright.dev/dotnet/docs/writing-tests#test-isolation "The Playwright NUnit and MSTest test framework base classes will isolate each test from each other by providing a separate Page instance." You can check authentication section in documentation as well to store the auth state. – Rahul L Dec 05 '22 at 05:07

0 Answers0