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

  1. require 'watir-webdriver'
  2. browser = watir::browser.new(:chrome)
  3. 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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -