Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running parallel selenium tests with capybara

Background:

I have a set of Capybara integration tests running against my Rails 3 Application. For the other parts of the test suite I'm using Rspec.

I have a selenium 2.6.0 standalone server hub on my Mac OSX dev machine.

java -jar selenium-server-standalone-2.6.0.jar -role hub

I'm running several virtual machines each hooked up to the hub with a selenium node:

java -jar selenium-server-standalone-2.6.0.jar -role webdriver -hub http://0.0.1.12:4444/grid/register port 5555 -browser browserName="internet explorer",version=8,platform=WINDOWS

This works fine, In this screenshot the console shows that I have an IE7 and an IE8 browser connected to the hub:

The hub console showing connected nodes

I've setup capybara to run against the selenium hub (that delegates the tests to the nodes).

Capybara.app_host = "myapp.dev"
Capybara.default_driver = :selenium
Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(app,
    :browser => :remote,
    :url => "http://localhost:4444/wd/hub",
    :desired_capabilities => :internet_explorer)
end

It works, however it will only run the test on a single internet_explorer node. It seems to be the one that is "first in line"; If i turn it off, the test will successfully run on the other node.

I've been trying out the parallel_tests project, configuring capybara as suggested, but that would still only launch one integration test.

How can I run my integration on all internet_explorer nodes simultaneously?

Bonus question: If i wanted to run my integration tests on all connected nodes, regardless of browser capability, how would i do that?

like image 242
Daniel Avatar asked Sep 27 '11 07:09

Daniel


2 Answers

Here you have to fire the same tests for different browser so can try to start two process of tests i.e. Run the same command twice.

As you have started the nodes the Grid will handle the execution on different nodes.

In your case you are executing the test and only on suite/process is started with respect to Grid. Just for testing Purpose try firing these tests twice one after another. If you are not able to Achieve by this Use Ant or similar thing to control your execution of tests.

like image 161
lAH2iV Avatar answered Sep 23 '22 19:09

lAH2iV


For IE webdrive you can run at most 1 test on one physical node! If you want to achieve parallelism with IE webdriver than you can try by add/register more physical node to the hub.

Regarding above screen shot of hub console, it also shows you only one IE icon. The message is wrong that "Supports up to 5 ...." but you can consider number of icon for respective browser displayed below it.

like image 37
user861594 Avatar answered Sep 22 '22 19:09

user861594