Watir can't find elements I see in Chrome's DOM Inspector
Asked Answered
C

1

6

Here's a study case:

<html>
...
<embed name="foo">
<embed name="bar">
...
</html>

I'm trying to reference the embed element named "bar" using Watir Ruby's API. The element is shown by Chrome's DOM Inspector but I can't find it using any of finding methods of Watir:

browser.embeds() # only <embed name="foo"> is found
browser.html.include? 'bar' # => false

Why does that happen? Why Watir does not show the complete HTML? If I have elements in different frames or dynamically inserted by Javascript init functions, will them be accessible using Watir?

Thanks

Contumelious answered 12/10, 2012 at 15:17 Comment(1)
Are these tags closed properly?Consolidate
R
3

If the element is in the frame, you have to use something like this:

browser.frame(:id => "frameid").embed(:name => "bar")
Ras answered 12/10, 2012 at 21:23 Comment(1)
Thanks! Now I'm looking for the best way to traverse all iFrames, as I don't know where exactly the frame containing the embed element will be.Contumelious

© 2022 - 2024 — McMap. All rights reserved.