Use test host configuration to set playwright options. #3
Replies: 2 comments
-
|
My knowledge is limited in Playwright framework... but what I have gathered for Playwright configuration... |
Beta Was this translation helpful? Give feedback.
-
|
@eric-vanartsdalen Playwright uses a number of POCO configuration objects to performs various operations, such as
I think we are generally in agreement here on the customization that can be done. See I've added a couple of example fixtures to show injecting/overriding configuration in the test and/or fixture. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
From #1 there is a possibility to load configuration for
PlaywrightWebApplicationFactoryfrom the host under test.This would allow many options to be set without overriding the respective property get function:
BrowserTypeLaunchOptionsContextOptionsPageOptionsIt would need to be decided what the configuration section name should be (at least by default) for these. In the proof of concept, I used.
To separate settings for the host, from the test factory, it might make sense to load additional setting from an
appSettings.jsonfile in the test project, and/or from user secret linked to the test project.The former can be achieved by code like
which could be called from
CreateHostand the latter byagain in
CreateHost.Technically, we could do something like
Which would work if the factory was subclassed as a fixture in the test project.
There is also a
GetTestAssembliesfunction in the baseMicrosoft.AspNetCore.Mvc.Testing.WebApplicationFactorywhich could perhaps be used.So, the questions are:
appSettings.json(or similar) be added from the test project by default?If should be possible to add predicate properties to allow overriding the default behaviour fairly easily - like
C3D.Extensions.Playwright.AspNetCore/src/C3D/Extensions/Playwright/AspNetCore.Xunit/Fixtures/PlaywrightFixture.cs
Lines 13 to 21 in d967c9e
Beta Was this translation helpful? Give feedback.
All reactions