From b83c8c29b6fb0086bb377b2f648e70e30a353c0e Mon Sep 17 00:00:00 2001 From: Sergey Ruzin Date: Mon, 11 Jul 2022 16:11:55 +0300 Subject: [PATCH] Minor fixes to playwright tests --- .../Behavioral.Automation.Configs.csproj | 1 - .../Behavioral.Automation.Playwright.csproj | 1 - .../Behavioral.Automation.Playwright/Hooks.cs | 10 ++++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Behavioral.Automation.Playwright/Behavioral.Automation.Configs/Behavioral.Automation.Configs.csproj b/Behavioral.Automation.Playwright/Behavioral.Automation.Configs/Behavioral.Automation.Configs.csproj index a0fc964f..1bbb437e 100644 --- a/Behavioral.Automation.Playwright/Behavioral.Automation.Configs/Behavioral.Automation.Configs.csproj +++ b/Behavioral.Automation.Playwright/Behavioral.Automation.Configs/Behavioral.Automation.Configs.csproj @@ -4,7 +4,6 @@ net6.0 enable enable - Debug;Release;Test;Dev;Prod AnyCPU diff --git a/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright.csproj b/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright.csproj index 1f35e31b..8242e22c 100644 --- a/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright.csproj +++ b/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright.csproj @@ -30,7 +30,6 @@ - diff --git a/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright/Hooks.cs b/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright/Hooks.cs index 004cc78b..562a92a9 100644 --- a/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright/Hooks.cs +++ b/Behavioral.Automation.Playwright/Behavioral.Automation.Playwright/Hooks.cs @@ -35,6 +35,12 @@ public Hooks(WebContext webContext, ScenarioContext scenarioContext, IObjectCont [BeforeTestRun] public static async Task InitBrowser() { + var exitCode = Program.Main(new[] { "install" }); + if (exitCode != 0) + { + throw new Exception($"Playwright exited with code {exitCode}"); + } + _playwright = await Microsoft.Playwright.Playwright.CreateAsync(); if (_playwright is null) throw new Exception("Failed to initialize playwright."); _browser = await InitBrowserAsync(); @@ -69,11 +75,11 @@ public async Task MakeScreenshot() var path = new string(TestContext.CurrentContext.Test.Name .Where(x => !Path.GetInvalidFileNameChars().Contains(x)) .ToArray()) + ".png"; - await _webContext.Page.ScreenshotAsync(new PageScreenshotOptions + await _webContext.Page.ScreenshotAsync(new PageScreenshotOptions { Path = path }); - + TestContext.AddTestAttachment(path); } }