panther icon indicating copy to clipboard operation
panther copied to clipboard

Possible to access iframe content?

Open njsa04 opened this issue 3 years ago • 3 comments

@dunglas thanks for making this project.

I've been trying different ways to access iframe content.

$crawler = $client->switchTo()->frame('myframe') 

doesn't seem to work.

is this functionality supported? any recommendations?

njsa04 avatar Mar 20 '21 02:03 njsa04

What are you using for myframe? I think that needs to be a selector object, not a string.

Here is some code I have working in production:

$client->waitForVisibility('#Container iframe');
$myFrame = $client->findElement(WebDriverBy::cssSelector('#Container iframe'));
$client->switchTo()->frame($myFrame);

And then afterwards:

$client->switchTo()->defaultContent();

halfer avatar Mar 25 '21 12:03 halfer

Is the crawler updated when we move from one frame to another? I tried what you said above, but I feel like I failed to switch to the frame, because I can't access a field in the frame, and the reverse, I can access a field from the default frame.

How to make sure to have correctly switched frames and to have the right crawler?

bastien70 avatar Apr 10 '21 09:04 bastien70

@bastien70 - I don't think I can help further. If you can provide a ready-to-go minimal reproducible sample in Docker Compose, I can take a look at it.

halfer avatar Apr 15 '21 22:04 halfer