2015-04-30 41 views
0

我有一个加载使用srcdoc属性,而不是从src。我想使用Watir-WebDriver单击按钮,但我无法弄清楚如何定位按钮,即使在具有id属性的中。无法访问srcdoc iframe内的按钮?

是否可以找到从srcdoc加载的中的元素?

<html> 
    <body> 
     <div id="iphone"> 
      <iframe id='ip1' srcdoc="<%= Nokogiri::HTML(my html code)%>"></iframe> 
     </div> 
    </body> 
</html> 
+0

我不积极(你的问题有点含糊),但这可能有帮助 - http://stackoverflow.com/questions/3275816/debugging-iframes-with-chrome-developer-tools – sfletche

回答

0

如果您正试图点击该按钮是一个iframe中,您将需要webdriver的焦点切换到该iframe第一。

这是因为iframe中的内容对WebDriver不可见,除非它当前专注于该iframe。