testing - Ruby Script that runs list of irb watir commands -
i regularly use irb testing out cucumber watir webdriver steps on browser. involves opening irb , typing in list of same commands. first few commands
- require 'watir-webdriver'
- browser = watir::browser.new(:chrome)
- b.goto 'www.foo.com'
the list of commands goes on this. every time open irb have go through of these. have idea of script run automate list of commands such above? open irb , go through commands 1 one saving me load of time.
any appreciated.
probably easiest thing create script.rb
file in root project directory (or wherever you're starting irb), , write out ruby run. when start irb, load 'script.rb'
however won't work if need access browser
variable after setup. in case make more sense create class.
in ./test_browser.rb
require 'watir-webdriver' require 'irb' class testbrowser < watir::browser def self.build browser = new(:chrome) browser.goto 'www.foo.com' # other setup steps browser # return browser @ end of method end end irb.start
then shell: $ ruby ./test_browser.rb
this start irb class loaded. need call .build
method , store browser in variable
browser = testbrowser.build
Comments
Post a Comment