I am working to convert some Selenium tests to use Selenium grid and am running into a problem.
The tests run fine using a browser on the local machine.
I created a new driver like this (in spec_helper.rb):
Capybara.register_driver :selenium_remote do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome
Selenium::WebDriver.for(:remote,
:url => 'http://gridhub:4444/grid/driver',
:desired_capabilities => caps)
end
When I run the tests with the new driver the hub is contacted and a node loads the Chrome driver, everything looks ok on the grid side.
The problem is that on the machine initiating the tests I am getting the following exception:
Failure/Error: Unable to find matching line from backtrace
SystemStackError:
stack level too deep
# /home/.rvm/gems/ruby-1.9.3-p194/gems/capybara-2.0.1/lib/capybara.rb:298
I created this bare bones test, and I am still seeing the same exception just running it:
Capybara.default_driver = :selenium_remote
describe 'I can' do
it 'visit Google without throwing an error' do
visit 'http://www.google.com'
end
end
I am using Selenium server standalone 2.26.0, Capybara 2.0.1 and RSpec 2.9.0.
Any ideas what is causing this?
Well, with the help of this blog post (http://www.softr.li/blog/2012/11/08/capybara-selenium-rspec-vagrant-remotely) I got it working.
The above blog post was based on another blog post (http://www.without-brains.net/blog/2012/08/01/capybara-and-selenium-with-vagrant).
It looks like I was registering the Capybara Selenium web driver incorrectly.
Below is the code from the blog post that correctly registers the driver. Just using it as-is fixed my issue, then I modified it for my own use.
The code is also in a gist (https://gist.github.com/4038197#file-capybara_remote-rb).
Create a new Ruby file, add this code, and include it in your spec_helper.rb file.
Now any RSpec example with the :js => true metadata will use this driver.