Q. How do I execute arbitrary javascript?
A. Use the .goto method to call the javascript …
Example html:
<HTML lang="en-US" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> <BODY scroll="no"> <script type="text/javascript" charset="utf-8"> function openWin(i){ alert(i); } </script> <DIV id="menuLayer1"> <DIV id="menuLite1"> <DIV id="menuFg1"> <DIV id="menuItem1" mmaction="location='javascript:openWin(2);'" zIndex="1"> <DIV id="menuItemText1"> <DIV id="menuItemShim1"> <DIV align="left"> just_add_watir </DIV> </DIV> </DIV> </DIV> </DIV> </DIV> </DIV> </BODY> </HTML>
Example watir:
@b.goto('http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0020.html') @b.div(:id, "menuItem1").flash @b.goto("javascript:openWin(2)")