playwright
playwright copied to clipboard
[BUG] 'Error: locator.click: Target page, context or browser has been closed' on playwright:v1.41.1
similar to issue 28500
System info
Playwright Version: 1.41.1 Operating System: both Mac and inside docker image playwright:v1.41.1 on CI (linux) Node.js version: v19.9.0 Browser: Chromium Reproduces: always
Source code
no source code
Steps
- Page under the test has upload (as part of the page)
- Playwright uploads the file:
const filePath = path.join(__dirname, `../data/${fileName}`) await this.page.setInputFiles(selector, filePath)
- Playwright clicks on
Add
button (inside the div) and then div disappears from the page - Playwright tries to click on the button at the top of the page to apply changes, but times out with error:
Error: locator.click: Target page, context or browser has been closed
re-initializing the page didn't help
This usually happens when you are making a call after the test has ended and the page is closed. If you have reasons to believe this is not the case, please provide full repro script.
ok, I'll see what I can do script-wise. Meanwhile I just want to add more detail: the page remains open, context and browser are not closed either. If I click on the 'Add' button myself (in headed mode) - the test will proceed! I hope this may give you some ideas, let me know if there's something I could try
Not really, we would need a repro!
Closing as non-actionable due to the lack of repro. Please open a new bug if you manage to create a repro we can use.
I have just had this issue myself, I resolved it by typing clear cache in the VS code terminal and then restarting VS code.
In my case it was a missing "await" in the last "if" one-liner, so it checked for "if" and stopped without executing the command.