26 lines
753 B
C#
26 lines
753 B
C#
namespace JdeScoping.Ui.Tests.Support;
|
|
|
|
public sealed class PlaywrightFixture : IAsyncLifetime
|
|
{
|
|
private IBrowser? _browser;
|
|
private IPlaywright? _playwright;
|
|
|
|
public IBrowser Browser => _browser ?? throw new InvalidOperationException("Browser is not initialized.");
|
|
|
|
public async Task InitializeAsync()
|
|
{
|
|
_playwright = await Playwright.CreateAsync();
|
|
_browser = await _playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
|
|
{
|
|
Headless = UiTestSettings.Headless,
|
|
Args = ["--no-sandbox", "--disable-dev-shm-usage"]
|
|
});
|
|
}
|
|
|
|
public async Task DisposeAsync()
|
|
{
|
|
if (_browser is not null) await _browser.CloseAsync();
|
|
|
|
_playwright?.Dispose();
|
|
}
|
|
} |