playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Question] While running a test with VSCode, browser closes when test is finished even though "Show browser" option is enabled

Open BekaOkromchedlidze opened this issue 2 years ago • 10 comments

I would like to utilise the new record at cursor feature but the browsers automatically close once the test has finished. Can anyone tell me is there a preference I have to change in order to keep the browser open?

Thanks

BekaOkromchedlidze avatar Nov 24 '22 13:11 BekaOkromchedlidze

Can you show us how your test looks like? Do you launch your browser or context manually?

If you use the page fixture which Playwright provides to you, the browser should stay open all the time.

mxschmitt avatar Nov 24 '22 21:11 mxschmitt

@mxschmitt I use the page fixture. Please take a look at an example below. I'm wondering if it is because I use global setup to save a logged in storage state. So, at setup I log in, save the state, browser closes and another browser opens once the test begins. image

BekaOkromchedlidze avatar Nov 25 '22 10:11 BekaOkromchedlidze

I can see you are overriding the fixtures in ../../../../fixtures/fixtures. You are probably overriding the page / context fixtures and close the page / context.

pavelfeldman avatar Nov 28 '22 01:11 pavelfeldman

Hi @pavelfeldman , I have created a custom fixture which extend playwright test object but I don't think I am overriding the page fixture. Could you please take a look below. Do you know what I could change to not override the page fixture? image

BekaOkromchedlidze avatar Nov 28 '22 11:11 BekaOkromchedlidze

I don't think the custom fixture is the problem. I have swapped to use the default playwright test instead and the issue is still happening. image

I have also removed the global setup login + save logged in state flow and this had no effect either. image

BekaOkromchedlidze avatar Nov 28 '22 12:11 BekaOkromchedlidze

@mxschmitt @pavelfeldman I've found the issue. The browser closes when trace collect option is set to 'on'. Can this be considered a bug? I would expect the trace save could be initiated once the user manually closes the browser? image

BekaOkromchedlidze avatar Nov 28 '22 13:11 BekaOkromchedlidze

I wonder if we should do the opposite instead: while in the 'Show browser' mode, we could disable tracing. Would that work for you? Or do you use traces in your dev workflow?

pavelfeldman avatar Nov 28 '22 17:11 pavelfeldman

@pavelfeldman I do use traces quite a lot during development, because it is such a great tool for having a good overview of what is exactly going on during the test in-case something isn't going quite as expected. However, your suggestion would also work. I would just toggle the Show Browser option off if I need to save and view the traces.

BekaOkromchedlidze avatar Dec 01 '22 08:12 BekaOkromchedlidze

I'm experiencing the exact same issue. The difference is that I set trace to 'retain-on-failure' in my playwright config. It would be really great if this could be fixed as it's very confusing that tracing being enabled is causing the browser to close after the test.

markbrockhoff avatar Dec 12 '22 16:12 markbrockhoff

I faced the same issue and it was due to using the video option:

  use: {
    video: {
      mode: 'retain-on-failure',
      size: { width: 640, height: 480 },
    },
}

I find this a bit misleading, would it be possible to automatically disable the video if the test in run with "Show browser"?

ValentinH avatar Dec 15 '22 13:12 ValentinH