Execute Javascript from Watir

To execute javascript from a Watir script you can use the following trick.

ie.document.parentWindow.execScript("window.open('#{url}', 'NAME')")

This particular script was usefull to simulate a popup window from a parent browser window. Opening a new window from Watir directly with

IE.new_process()

creates a second browser window that is “not trusted” from the originating browser window.

Also make sure that the web application is from a trusted “local intranet” site in IE, otherwise you get security violation errors.