While using Watir, I have the ability to access the methods of the iframes on the page:
browser.iframes.map(&:contentwindow)
# => ["", "", ""]
However, if I try to access the iframes using JavaScript within the same context where I executed the Watir code, I encounter a block for all the iframes:
script =<<-ENDHEREDOC
var i = 1;
var iframes = document.querySelectorAll('iframe');
all = [];
for (i = 0; i < iframes.length; i++) {
all.push(iframes[i].contentWindow);
}
return all;
ENDHEREDOC
elements = browser.execute_script(script)
Selenium::WebDriver::Error::NoScriptResultError: move target out of
bounds: Blocked a frame with origin "https://my_site.atlassian.net" from accessing a cross-origin frame.
I believe that Watir, similar to phantomjs, may have a setting like web-security
which is initially set to false. However, it appears that the security settings are enabled again when running scripts. Is there a way to maintain the security settings turned off even for scripts?