0

I have an <iframe> loaded using a srcdoc attribute, not from src. I want to click the button using Watir-WebDriver, but I can't figure out how to locate the button, even in an <iframe> with an id attribute.

Is it possible to locate elements in an <iframe> loaded from srcdoc?

<html>
    <body>
        <div id="iphone">
            <iframe id='ip1' srcdoc="<%= Nokogiri::HTML(my html code)%>"></iframe>
        </div>
    </body>
</html>
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
M.R
  • 610
  • 2
  • 10
  • 34
  • i'm not positive (your question is a little vague), but this may help - http://stackoverflow.com/questions/3275816/debugging-iframes-with-chrome-developer-tools – sfletche Apr 30 '15 at 04:47

1 Answers1

0

If the button you are attempting to click is within an iframe, you will need to make WebDriver switch focus to that iframe first.

This is because the content within an iframe is not visible to WebDriver unless it is currently focused on that iframe.

Tom Trumper
  • 472
  • 2
  • 8