playwright
playwright copied to clipboard
[Question] While running a test with VSCode, browser closes when test is finished even though "Show browser" option is enabled
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
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 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.
I can see you are overriding the fixtures in ../../../../fixtures/fixtures. You are probably overriding the page / context fixtures and close the page / context.
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?
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.
I have also removed the global setup login + save logged in state flow and this had no effect either.
@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?
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 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.
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.
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"?