Skip to content

Commit 888c053

Browse files
authored
Fix InvalidOperationException in Selectors when running parallel tests (#3208)
1 parent 8a07fd2 commit 888c053

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Playwright/Core/Selectors.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public async Task RegisterAsync(string name, SelectorsRegisterOptions? options =
5353
{
5454
engine["contentScript"] = options.ContentScript;
5555
}
56-
foreach (var context in _contextsForSelectors)
56+
foreach (var context in _contextsForSelectors.ToArray())
5757
{
5858
await context.SendMessageToServerAsync("registerSelectorEngine", new Dictionary<string, object?>
5959
{
@@ -67,7 +67,7 @@ public void SetTestIdAttribute(string attributeName)
6767
{
6868
Locator.SetTestIdAttribute(attributeName);
6969
_testIdAttributeName = attributeName;
70-
foreach (var context in _contextsForSelectors)
70+
foreach (var context in _contextsForSelectors.ToArray())
7171
{
7272
context.SendMessageToServerAsync(
7373
"setTestIdAttributeName",

0 commit comments

Comments
 (0)