ruby - How can i test multiple Browsers in one Watir Script using test-unit gem -



ruby - How can i test multiple Browsers in one Watir Script using test-unit gem -

so not running multiple browsers in parallel. sequentially running ie11, ie10, firefox, of them on different virtual machines connected selenium grid2.

here have, running 1 browser on 1 vm.

file: example_grid_ie11.rb

require "rubygems" require "test/unit" require "watir-webdriver" class googlesearch < test::unit::testcase def setup caps = selenium::webdriver::remote::capabilities.ie caps.version = "11" caps[:name] = "testing ie 11" @browser = watir::browser.new( :remote, :url => "http://vm-auto.3mhis.vm:4444/wd/hub", :desired_capabilities => caps) end def teardown @browser.close end def test_search @browser.goto "google.com" @browser.text_field(:name => "q").set "watir" @browser.button.click @browser.div(:id => "resultstats").wait_until_present @browser.screenshot.save ("googlesearch_ie11.png") assert @browser.title == "watir - google search" end end

now, not figure out if can run multiple setup methods , multiple tear-downs, , browser close in teardown.

test-unit gem, gives me nice result xunit style, plus lot of asserts.

use test::unit 2.x

gem install test-unit

example:

https://github.com/test-unit/test-unit

multiple setups:

class tc_mytest < test::unit::testcase def setup # first @standard = myclass.new end setup # sec def setup_alpha @alpha = myclass.new end setup # 3rd def setup_beta @beta = myclass.new end def test_stuff assert_true(1 == 1) end end

multiple teardowns:

class tc_mytest < test::unit::testcase def test_stuff assert_true(1 == 1) end def teardown # lastly @standard = nil end teardown # sec def teardown_alpha @alpha = nil end teardown # first def teardown_beta @beta = nil end end

ruby selenium watir-webdriver testunit selenium-grid2

Comments