playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] 'Error: locator.click: Target page, context or browser has been closed' on playwright:v1.41.1

Open Valentyna opened this issue 1 year ago • 3 comments

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

Valentyna avatar Jan 29 '24 19:01 Valentyna

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.

pavelfeldman avatar Jan 29 '24 22:01 pavelfeldman

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

Valentyna avatar Jan 30 '24 16:01 Valentyna

Not really, we would need a repro!

pavelfeldman avatar Jan 30 '24 16:01 pavelfeldman

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.

pavelfeldman avatar Feb 02 '24 20:02 pavelfeldman

I have just had this issue myself, I resolved it by typing clear cache in the VS code terminal and then restarting VS code.

craitose avatar Mar 14 '24 17:03 craitose

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.

eifcgn24 avatar Mar 30 '24 15:03 eifcgn24