Why does Watir-webdriver open two browsers?

advertisements

I'm working on website test automation using Cucumber/Ruby/Selenium-Webdriver/Capybara. I want to switch to Watir-Webdriver in combination with Cucumber and Ruby, but I'm struggling with the following:

Every time I run my cucumber test, Watir opens two browser windows, a blank screen to the site I configurated as default, plus another in which the actual test steps are executed.

My 'Support/env.rb' file has:

require 'allure-cucumber'
require 'rspec'
require 'watir-webdriver'

AllureCucumber.configure do |c|
  c.output_dir = 'D:\Test\result'
  c.clean_dir  = true
  c.tms_prefix      = '@PRACTEST--'
  c.issue_prefix    = '@JIRA++'
  c.severity_prefix = '@URGENCY:'
  c.tms_prefix =  ''
end

My steps file begins with:

require 'watir-webdriver'
require 'cucumber'
require 'rspec'
require_relative 'D:\EntelTest\src\PageObject\home_page.rb'

Before  do
  @test = AbstractPage.new(Watir::Browser.new :ff)
  @test.full_size
end

After  do
  @test.quit
end

home_page = nil

When(/^Go to home page$/) do
  home_page  = @test.goToHomePage

end


Can you put these before do and after do in hooks.rb? In the steps.rb file, just mention the code for your cucumber steps, and before that declare browser = Watir::Browser.new :ff

The best practice is to put it in hooks.rb. env.rb usually should consist the desired capabilities plus server environment codes. :)