Skip to content

Commit 2f609be

Browse files
committed
Wait for BrowserStack local to start
1 parent 496484b commit 2f609be

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Tests/CSF.Screenplay.Selenium.Tests/BrowserStack/BrowserStackExtension.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Configuration.Assemblies;
43
using System.Linq;
54
using System.Net.Http;
65
using System.Net.Http.Headers;
@@ -9,7 +8,6 @@
98
using System.Text;
109
using BrowserStack;
1110
using CSF.Screenplay.Performances;
12-
using Microsoft.Extensions.DependencyInjection;
1311

1412
namespace CSF.Screenplay.Selenium.BrowserStack;
1513

@@ -21,12 +19,18 @@ public sealed class BrowserStackExtension : IDisposable
2119
IHasPerformanceEvents? eventBus;
2220
HttpClient? httpClient;
2321

24-
public void OnTestRunStarting()
22+
public async Task OnTestRunStarting()
2523
{
2624
if(!BrowserStackEnvironment.IsBrowserStackTest()) return;
2725

2826
browserStackLocal = new Local();
2927
browserStackLocal.start(GetBrowserStackLocalArgs().ToList());
28+
for(var i = 0; i < 10; i++)
29+
{
30+
await Task.Delay(250);
31+
if(browserStackLocal.isRunning()) break;
32+
}
33+
if(!browserStackLocal.isRunning()) throw new TimeoutException("BrowserStack Local is still not running after 2.5 seconds");
3034

3135
httpClient = GetHttpClient();
3236

Tests/CSF.Screenplay.Selenium.Tests/TestWebappSetupAndTeardown.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public async Task StartWebAppAsync()
2323
await WaitForWebAppToBeAvailableAsync();
2424

2525
browserStack = new BrowserStackExtension();
26-
browserStack.OnTestRunStarting();
26+
await browserStack.OnTestRunStarting();
2727
}
2828

2929
[OneTimeTearDown]

0 commit comments

Comments
 (0)