Skip to content

Commit 5717749

Browse files
committed
Automatically install required browser files for Playwright
This will prevent this exception: > Microsoft.Playwright.PlaywrightException > Executable doesn't exist at ~/Library/Caches/ms-playwright/chromium-1148/chrome-mac/Chromium.app/Contents/MacOS/Chromium > ╔════════════════════════════════════════════════════════════╗ > ║ Looks like Playwright was just installed or updated. ║ > ║ Please run the following command to download new browsers: ║ > ║ ║ > ║ pwsh bin/Debug/netX/playwright.ps1 install ║ > ║ ║ > ║ <3 Playwright Team ║ > ╚════════════════════════════════════════════════════════════╝ > at Microsoft.Playwright.Transport.Connection.InnerSendMessageToServerAsync[T](ChannelOwner object, String method, Dictionary`2 dictionary, Boolean keepNulls) in /_/src/Playwright/Transport/Connection.cs:line 206 > at Microsoft.Playwright.Transport.Connection.WrapApiCallAsync[T](Func`1 action, Boolean isInternal) in /_/src/Playwright/Transport/Connection.cs:line 535 > at Microsoft.Playwright.Core.BrowserType.LaunchAsync(BrowserTypeLaunchOptions options) in /_/src/Playwright/Core/BrowserType.cs:line 56 > at Microsoft.Playwright.Xunit.BrowserService.CreateBrowser(IBrowserType browserType) in /_/src/Playwright.Xunit/BrowserService.cs:line 56 > at Microsoft.Playwright.Xunit.BrowserService.<>c__DisplayClass5_0.<<Register>b__0>d.MoveNext() in /_/src/Playwright.Xunit/BrowserService.cs:line 46 > --- End of stack trace from previous location --- > at Microsoft.Playwright.Xunit.WorkerAwareTest.RegisterService[T](String name, Func`1 factory) in /_/src/Playwright.Xunit/WorkerAwareTest.cs:line 54 > at Microsoft.Playwright.Xunit.BrowserTest.InitializeAsync() in /_/src/Playwright.Xunit/BrowserTest.cs:line 45 > at Microsoft.Playwright.Xunit.ContextTest.InitializeAsync() in /_/src/Playwright.Xunit/ContextTest.cs:line 35 > at Microsoft.Playwright.Xunit.PageTest.InitializeAsync() in /_/src/Playwright.Xunit/PageTest.cs:line 35 This helps with #2286.
1 parent 2a21386 commit 5717749

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/Playwright.MSTest/WorkerAwareTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public void WorkerSetup()
4646
{
4747
_currentWorker = new();
4848
}
49+
50+
new Program().Run(["install", "--with-deps", PlaywrightSettingsProvider.BrowserName], throwOnError: true);
4951
}
5052

5153
[TestCleanup]

src/Playwright.NUnit/WorkerAwareTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public void WorkerSetup()
7070
{
7171
AssertionsBase.SetDefaultTimeout(PlaywrightSettingsProvider.ExpectTimeout.Value);
7272
}
73+
74+
new Program().Run(["install", "--with-deps", PlaywrightSettingsProvider.BrowserName], throwOnError: true);
7375
}
7476

7577
[TearDown]

src/Playwright.Xunit/WorkerAwareTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ async public override Task InitializeAsync()
6969
{
7070
AssertionsBase.SetDefaultTimeout(PlaywrightSettingsProvider.ExpectTimeout.Value);
7171
}
72+
73+
new Program().Run(["install", "--with-deps", PlaywrightSettingsProvider.BrowserName], throwOnError: true);
7274
}
7375

7476
public async override Task DisposeAsync()

0 commit comments

Comments
 (0)