I have a need to locate elements, whether within the top-level document, or within nested containers (iframe/embed/object).
I've written a recursive version of the elements method, but during testing, I noticed that for container elements that load and render dynamic content, the elements render just fine, but the dynamic content doesn't seem to be available to watir.
HTML
<embed src="https://example.com/">
Ruby
element.embeds.each do | embed |
puts embed.elements( css: '*' ).length
end
This just gives me 0 elements, when I would expect to be able to see the contents of the embed too.
What am I missing?
Currently, Watir has no special handling for
embedelements. However, it seems that Selenium should be able to interact with them if treated like aniframe.You can add a custom Watir class/method to treat
embedlikeiframe(specifically the logic for switching to/from inside theembedelement):Then you can use the normal Watir methods:
If this works for you, we can see about adding it to the Watir repository.