Closed brbrr closed 9 years ago
What watir/selenium gems do you have in your Gemfile and how do you require those dependencies?
my Gemfile:
# watir related
gem 'watir-webdriver'
gem 'watir-rspec'
and my spec_helper:
require 'watir-webdriver'
require 'watir/rspec'
So I using latest 0.7.0 watir-webdriver and 2.0.3 watir-rspec on ruby 2.2.0
Do like this instead:
# Gemfile
group :test do
gem "watir-rspec"
end
and in spec_helper.rb
do not require any watir-related gems because Bundler already requires watir-rspec
, which in turn loads everything needed in correct order.
When I removing require 'watir/rspec'
from spec_helper.rb
I got uninitialized constant Watir::RSpec (NameError)
as I've used watir-rspec install
I using watir for black box test automation (no Rails or similar)
Did you use bundler to run your specs? It seems as you did execute rspec directly without bundler exec rspec
.
Yup, thats true. I use RubyMine's run command - thats handy to run single example
update: same with bundler exec
$ bundler exec rspec login_spec
/spec/spec_helper.rb:36:in `block in <top (required)>': uninitialized constant Watir::RSpec (NameError)
If i'm not mistaken then Rubymine should have full Bundler support in it as well so even if you'd run single example it still use Bundler. But that's a completely different problem which you should fix as well :) However, until then, just add that watir-rspec require back to your spec_helper then.
On Tue, May 26, 2015 at 11:31 AM, Iaroslav Kukharuk < notifications@github.com> wrote:
Yup, thats true. I use RubyMine's run command - thats handy to run single example
— Reply to this email directly or view it on GitHub https://github.com/watir/watir-rspec/issues/13#issuecomment-105444841.
OK, I found what cause such issue - page-object gem. Check this code:
require 'page-object'
require 'watir/rspec'
RSpec.configure do |config|
config.before(:all) do
browser = Watir::Browser.new :firefox
end
config.include Watir::RSpec::Helper
end
describe 'test' do
it 'google.com' do
browser.goto("http://www.google.com")
sleep 5
browser.close
end
end
How can you be sure that page-object gem is to blame with that code?
On Tue, May 26, 2015 at 1:12 PM, Iaroslav Kukharuk <notifications@github.com
wrote:
OK, I found what cause such issue - page-object gem. Check this code:
require 'page-object' require 'watir/rspec'
RSpec.configure do |config|
config.before(:all) do browser = Watir::Browser.new :firefox end config.include Watir::RSpec::Helper
end
describe 'test valid' do it 'test test', :smoke do browser.goto("http://www.google.com") sleep 5 browser.close end end
— Reply to this email directly or view it on GitHub https://github.com/watir/watir-rspec/issues/13#issuecomment-105477094.
I've create test_spec.rb
with code bellow, and run it as rspec test_spec.rb
from command line(make sure p-o is before watir)
run it and ged:
1) test google.com
Failure/Error: @browser = Watir::Browser.new :firefox
SystemStackError:
stack level too deep
# ./test_spec.rb:7:in `new'
# ./test_spec.rb:7:in `block (2 levels) in <top (required)>'
than I run same code but with commented require 'page-object'
and test passed.
what is interesting:
require 'watir/rspec'
require 'page-object'
...
not cause such error
I don't know inner workings of page-object gem, but maybe it does something to trigger that error.
Try like this: require "watir/rspec" browser = Watir::Browser.new :firefox require "page-object" browser.goto("http://www.google.com")
J.
On Wed, May 27, 2015 at 4:15 PM, Iaroslav Kukharuk <notifications@github.com
wrote:
I've create test_spec.rb with code bellow, and run it as rspec test_spec.rb from command line(make sure p-o is before watir) run it and ged:
1) test google.com Failure/Error: @browser = Watir::Browser.new :firefox SystemStackError: stack level too deep
./test_spec.rb:7:in `new'
# ./test_spec.rb:7:in`block (2 levels) in <top (required)>'
than I run same code but with commented require 'page-object' and test passed. what is interesting:
require 'watir/rspec' require 'page-object'
...
not cause such error
— Reply to this email directly or view it on GitHub https://github.com/watir/watir-rspec/issues/13#issuecomment-105903193.
Closing this due to inactivity.
In my project which already running with selenium-webdriver I decide to try watir w/ watir-rspec gems. I create driver instance via:
@driver = Watir::Browser.new :firefox
and if watir-spec is required - I got 'SystemStackError: stack level too deep' errorI've tried to debug it w/ and w/out requiring gem:
in first case it cause circular reference in
initialize
method which cause such exception.Ask me for any additional info - would be happy to share.