30Sep/08Off
Q. How do I pass command line arguments to Test::Unit?
A. Use the -- argument to stop processing Test::Unit specific arguments ...
Module Test::Unit has its own command line arguments as specified by the following:
~/just_add_watir $>ruby test_suite.rb --help
Test::Unit automatic runner.
Usage: test/unit/graph_test.rb [options] [-- untouched arguments]
-r, --runner=RUNNER Use the given RUNNER.
(c[onsole], f[ox], g[tk], g[tk]2, t[k])
-n, --name=NAME Runs tests matching NAME.
(patterns may be used).
-t, --testcase=TESTCASE Runs tests in TestCases matching TESTCASE.
(patterns may be used).
-v, --verbose=[LEVEL] Set the output level (default is verbose).
(s[ilent], p[rogress], n[ormal], v[erbose])
-- Stop processing options so that the
remaining options will be passed to the
test.
-h, --help Display this help.
Deprecated options:
--console Console runner (use --runner).
--gtk GTK runner (use --runner).
--fox Fox runner (use --runner).Example watir:
def test_0021 # need to call test unit with -- argument puts "argument 1 is: ",ARGV[0] end
30Sep/08Off
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)")