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

Wait for iframe #640

Open
andreas-globi opened this issue Jul 23, 2024 · 2 comments
Open

Wait for iframe #640

andreas-globi opened this issue Jul 23, 2024 · 2 comments

Comments

@andreas-globi
Copy link

In the man DOM, you can use JS to click on an element, and use waitForPageReload() to wait for the reload to complete

eg:

$page->evaluate($code)->waitForPageReload();

But if you're clicking on an element in an iframe that causes the iframe to reload, waitForPageReload() won't work because the main page doesn't reload.

waitForResponse() doesn't work either, because the next call could be broken due to the iframe reloading.

How can we evaluate() and then wait for the iframe to reload?

@enricodias
Copy link
Member

I don't think iframes fire onload events or anything similar. You would have to inspect the iframe's content manually in a loop until the info you are looking for gets loaded there.

@andreas-globi
Copy link
Author

That's what I'm trying.

The issue though is that occasionally an exception is thrown while evaluating when the evaluate call is made DURING the iframe reload.

I get the same issue with the main page, but waitForPageReload() fixes it there.

I guess I could just try catch the iframe evals until a timeout is hit.

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

No branches or pull requests

2 participants