playwright
playwright copied to clipboard
I keep getting `locator.click: Target closed` on GitHub CI while everything passes on my local environment
Here is a snippet of where we are experiencing the problem
i am also getting same issue today. many times
locator.click: Target closed =========================== logs =========================== waiting for locator('button[class='btn btn']')
Page also crashing
@Onokaev usually that is how a missing await somewhere in your test manifests itself. Please make sure that e.g. all calls to the function are awaited.
It's harder to say anything more than this without the actual repro that we can look at & debug. Feel free to re-file with a proper repro so that we can be more helpful!
Your report does not give us much to work with. We can't run it (we can't even copy code from an image). And you did not provide us with an actual error message - which click did not work? I can see at least 3 clicks in the snippet, you know which one failed, we don't.
When something like this happens, you should use debugging tools to locate the problem. Did you look at the trace? It would probably point you to the problem immediately. If not, could you attach it? Note that it might have sensitive information, so if that is the case you need to pass it to us via non-GitHub public channels.
I don't think you are missing any awaits, in fact you have more than needed:
This does not need an await:
await expect(popup).toBeDefined()
This does not need an await, the next check is a noop, locator always returns something.
const finalStep = await page.locator('...')
I have re-created the part that's causing the problem here: https://codesandbox.io/s/eager-moore-wygo9m
My test is failing on the final click on line 52

I ran your script and it passed for me. It does not seem to follow the best practices for the authentication, but it worked. You should also remove all the toBeDefined and waitForTimeout calls, they only make the test go slower.
Closing as per above, please feel free to open a new issue if this does not cover your use case.