A bespoke CMS I worked on included a Web Form containing iframes of which one contained an Angular app. I wanted to access this Angular app using Watir-WebDriver and perform actions on its elements.
<div class="content">
<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize(
"ctl00$ContentPlaceHolderInner$_scriptManager1",
"aspnetForm",
[],
[],
[],
90,
"ctl00"
);
//]]>
</script>
<iframe
id="form-iframe"
src="http://weneedtogodeeper/"
style="border: none; height:1069px; width: 100%;"
>
</iframe>
</div>
Whilst the method for accessing iframes with Watir-WebDriver used to be frames
, I couldn't access the desired iframe with @b.frame(:id => "form-iframe")
and @b.frames
was empty.
Instead, use @b.iframes
. For example, @i = @b.iframes(:id => "form-iframe")
allowed me to work with the desired iframe as a new instance variable @i
.