Search code examples
rubyiframewatir

Access an element in an iframe watir


How to access an element inside an external iframe in watir?

<iframe src="externalurl">
<html>
<body>
<div class="hello">hello</div>
<form src="externalurl">
<div class="classInFormInIframe"></div>
</form>
</body>
</iframe>

How can i access the div inside the form with the external url too?


Solution

  • This code will access the div

    b.iframe(src: 'externalurl').form(src: 'externalurl').div
    

    If you want to trigger any action like click then

    b.iframe(src: 'externalurl').form(src: 'externalurl').div.click