Skip to content

[Bug]: Can't launch two Firefox contexts #35216

@Aimeast

Description

@Aimeast

Version

1.50.0 (Playwright for .NET)

Steps to reproduce

static async Task Main(string[] args)
{
    var contextOptions = new BrowserTypeLaunchPersistentContextOptions { Headless = true };
    var playwright = await Playwright.CreateAsync();
    var content1 = await playwright.Firefox.LaunchPersistentContextAsync(@"C:\Users\xx\Desktop\test\ff", contextOptions);
    var content2 = await playwright.Firefox.LaunchPersistentContextAsync(@"C:\Users\xx\Desktop\test\ff", contextOptions);

    var page1 = await content1.NewPageAsync();
    var page2 = await content2.NewPageAsync();

    await page1.CloseAsync();
    await page2.CloseAsync();

    await content1.CloseAsync();
    await content2.CloseAsync();

    playwright.Dispose();
}

Expected behavior

There are no errors after the execution is completed

Actual behavior

When executing on second playwright.Firefox.LaunchPersistentContextAsync,

  • First, Firefox pops up the error window: Firefox is already running, but is not responding. The old Firefox process must be closed to open a new window.

Image

  • Then, playwright throw the exception: TargetClosedException. details:
Microsoft.Playwright.TargetClosedException
  HResult=0x80131500
  Message=Target page, context or browser has been closed
Browser logs:

<launching> C:\Users\xx\AppData\Local\ms-playwright\firefox-1471\firefox\firefox.exe -no-remote -headless -profile C:\Users\xx\Desktop\test\ff -juggler-pipe about:blank
<launched> pid=22724
[pid=22724][err] *** You are running in headless mode.
[pid=22724] <process did exit: exitCode=0, signal=null>
[pid=22724] starting temporary directories cleanup
Call log:
  -   - <launching> C:\Users\xx\AppData\Local\ms-playwright\firefox-1471\firefox\firefox.exe -no-remote -headless -profile C:\Users\xx\Desktop\test\ff -juggler-pipe about:blank
  -   - <launched> pid=22724
  -   - [pid=22724][err] *** You are running in headless mode.
  -   - [pid=22724] <process did exit: exitCode=0, signal=null>
  -   - [pid=22724] starting temporary directories cleanup
  Source=Microsoft.Playwright
  StackTrace:
   at Microsoft.Playwright.Transport.Connection.<InnerSendMessageToServerAsync>d__40`1.MoveNext()
   at Microsoft.Playwright.Transport.Connection.<WrapApiCallAsync>d__52`1.MoveNext()
   at Microsoft.Playwright.Core.BrowserType.<LaunchPersistentContextAsync>d__11.MoveNext()
   at TestPwTwoContent.Program.<Main>d__0.MoveNext() in C:\Users\xx\source\repos\TestPwTwoContent\TestPwTwoContent\Program.cs:line 12
  • But, if change to chrome, everything is OK.
var content1 = await playwright.Chromium.LaunchPersistentContextAsync(@"C:\Users\xx\Desktop\test\chrome", contextOptions);
var content2 = await playwright.Chromium.LaunchPersistentContextAsync(@"C:\Users\xx\Desktop\test\chrome", contextOptions);

Additional context

No response

Environment

Microsoft Windows [版本 10.0.19045.5608]

net9.0

Playwright for .NET 1.50.0

firefox-1471

chromium-1155

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions