Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I keep getting locator.click: Target closed on GitHub CI while everything passes on my local environment #19322

Closed
Onokaev opened this issue Dec 7, 2022 · 6 comments

Comments

@Onokaev
Copy link

Onokaev commented Dec 7, 2022

image

Here is a snippet of where we are experiencing the problem
@k87perera
Copy link

i am also getting same issue today. many times

locator.click: Target closed
=========================== logs ===========================
waiting for locator('button[class='btn btn']')

Page also crashing

@aslushnikov
Copy link
Collaborator

@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!

@pavelfeldman
Copy link
Member

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('...')

@Onokaev
Copy link
Author

Onokaev commented Dec 15, 2022

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
image

@pavelfeldman
Copy link
Member

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.

@pavelfeldman
Copy link
Member

Closing as per above, please feel free to open a new issue if this does not cover your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants