Run Rspec tests on multiple browser parallely as like TestNG

6 views
Skip to first unread message

Maheswaran Palanisamy

unread,
Nov 15, 2018, 5:16:34 AM11/15/18
to rspec
I want to run my scripts on both firefox and chrome at a time in rspec. wanted to know is it possible ? 

And My Driver.rb file looks like

RSpec.configure do |config|
config.before(:all) do


###############################################################################################################################################
####Running in Multiple browsers
###############################################################################################################################################


def firefox()
puts "begin firefox"
path = File.dirname(__FILE__) + "/driver/geckodriver"
begin
@driver = Selenium::WebDriver.for :firefox
puts "Starting tests, initializing " + @driver.inspect()
rescue Exception=>e
puts "Start Exception"
puts e.message
puts e.backtrace.inspect
raise e
end
@base_url = @test_env['url']
@driver.manage.window.maximize
@accept_next_alert = true
@driver.manage.timeouts.implicit_wait = DEFAULT_WAIT_TIME
end


def chrome
puts "begin chrome"
path = File.dirname(__FILE__) + "/../driver/chromedriver"
prefs = {:download => {:prompt_for_download => false, :default_directory => "#{ENV['PATH']}", :url => @base_url} }
@driver = Selenium::WebDriver.for :chrome, :prefs => prefs
@base_url = @test_env['url']
@accept_next_alert = true
end

begin
puts "begin firefox"
firefox
rescue Exception=>e
# Exception already displayed, exiting
puts "Exception Found: #{e}"
raise e
@driver.quit
end


config.after(:all) do
puts "Finishing tests, killing " + @driver.inspect()
@driver.quit
end
Reply all
Reply to author
Forward
0 new messages