Hello,

I am having a hard time to understand how to instantiate my Browser.

I have found a way to make my script working but I do not why and what I 
really should be doing...

Here is my script that is failing:

##################    FILE_SPEC.RB    ####################

browser = Watir::Browser.new :firefox
@b.goto("http://mytest/website";)

RSpec.configure do |config|
  config.before(:each) { @b = browser }
  config.after(:suite) { browser.close unless browser.nil? }
end

context 'Testing reports of Type = 2' do
  describe 'Given I am logging into QC as a ValidUser' do
    @validUser = User.new(@b, 'validuser','mysecretpassword')
    @validUser.log_in_as('validuser','mysecretpassword')

    it 'The ValidUser is taken to the Dashboard page' do
      # @b = browser
      expect(@b.text).to include('Welcome back,  ValidUser  |  Log out')
    end
  end
end
########################################################
=>
#####       OUTPUT     ######

An error occurred while loading ./spec/report_spec.rb.
Failure/Error: @b.text_field(:id, 'UserName').set username

NoMethodError:
  undefined method `text_field' for nil:NilClass
# ./lib/user.rb:12:in `log_in_as'
# ./spec/report_spec.rb:66:in `block (2 levels) in <top (required)>'
# ./spec/report_spec.rb:64:in `block in <top (required)>'
# ./spec/report_spec.rb:62:in `<top (required)>'
No examples found.

Finished in 0.42119 seconds (files took 9.08 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
########################################################

*What I have tested*:
 1) Now if I declare "@b = browser" under my 'context'  even using a 
config.before(:each) => Still it does not work 
 2) But *when add @b = browser under the 'describe block => Then it runs 
fine*

Could someone explain to me the logic here and what would be a good 
practice.

Thanks
JFF

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/6eafe33b-310e-4044-a475-0059bd82ad1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to