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>
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.