Running parallel selenium tests with capybara - ruby-on-rails

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:
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?

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.

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.

Related

Is it possible to run webdriverio app tests against AWS Device Farm without uploading the test suite?

We currently have a suite of webdriverio/appium tests for our react native app, with separate wdio.conf files for local, simulator, BrowserStack etc.
All of the examples I can find for device farm either involve first uploading the test suite as a zip up front, or creating a custom test runner that obtains a selenium grid url from Device Farm and then triggers the wdio command (but I can only see this being used for Selenium, nothing for appium/app testing).
Is it not possible to run tests from my local machine whilst pointing to AWS Device Farm devices?
Unfortunately this is not possible with AWS Device Farm, as you have already noticed that they do not have a Selenium Grid for mobile devices. In general for me it has been a huge hassle to get Appium tests to work on AWS using CI/CD - both because of the setup and the inability to easily debug since I can't run the tests locally against their devices. I would advise using another cloud farm service like Browserstack which allows you to target their grid from your local machine

Running multiple headless chrome sessions with docker

Is it possible to have setup a multiple headless chrome in a docker, since the current version of headless chrome does not support multiple sessions. I need to run tests in a isolations between browser with their own session.
Can someone point me to the right documentations?

Rails system test with capybara and headless selenium browser in Docker

TL;DR: Any idea about how to properly configure capybara to be able to drive a remote selenium browser in a docker container with default Rails minitest system test?
I'm running Rails in a dockerized env..
Now I want to start some "system tests" but since I'm running inside Docker I come up with some issues.
I'm using the default test suite (minitest?) with capybara and selenium-webdriver gems.
I've already installed the chromedriver packet in the container using the following:
RUN apt-get install -y chromedriver \
&& ln -s /usr/lib/chromium-browser/chromedriver /usr/local/bin
But running rails test:system outputs the following error Selenium::WebDriver::Error::WebDriverError: Unable to find chromedriver.
In fact I don't know if chrome itself is installed or not?
which chrome outputs nothing.
which chromium outputs /usr/bin/chromium.
I also tried with xvfb without success.
So (since I had no clue) I tried to go further and actually go with a dockerized system test environment as well.
I found some Docker images from selenium. So I ran among my rails and database containers a selenium-standalone-chrome container (the actual docker-compose.yml I'm using is here)
Then I found some useful information about the configuration to be done to let capybara driver the remote selenium browser.
All the examples I found on internet use rspec, but since I'm using the default minispec I tried to adapt the capybara driver to minispec but I had some doubt about how to do it and where to put the configuration.
For system tests I guessed that the best location is the file application_system_test_case.rb. Also I found and I tried many different capybara configurations and I end up with the following which seems to be the most complete (available here)
At that moment the test seems to perform well since I have no error but it always fails.
It fails regardless of making a call to the driver configuration (the setup_remote method where I defined the server host and port) before the tests case.
With or without the call I got the "site can't be reached" error (here is the screenshot)
Here is the test file I used. (Testing some react dynamic display)
However I can access to the selenium container with the given URL from the browser from my host machine. And both containers sees each others. I did some ping from within the containers shell.
The following SO questions being helpful don't work for me:
Dockerized selenium browser cannot access Capybara test url
How can I run headless browser system tests in Rails 5.1?
Any idea about how to properly configure capybara to be able to drive a remote selenium browser in a docker container with default Rails minitest system test?
Thank you very much.
You have to override the host method so Capybara uses the container's IP address. Check out this post: https://medium.com/#pacuna/using-rails-5-1-system-tests-with-docker-a90c52ed0648

I want to make a Test Lab setup for Appium

I want to make a Test Automation Lab for Appium (Android & iOS)
Questions:
1. As per Appium limitation we can access Single device (ios) from Machine.
In this case If I connect multiple Ios/Android devices to MAC machine (Server) how I can access from other machine ?
If I make Windows machine as a server Can I access and Run scripts from MAC machine?
You can use the selenium grid with Appium to do that. parallel test with appium & selenium grid
you have to add the appium in environment variable
start the grid
start the node which you want then run in parallel
You can go for sauce labs, Sauce Labs allows users to run tests in the cloud on more than 500 different browser platform, operating system and device combinations, providing a comprehensive test infrastructure for automated and manual testing of desktop and mobile applications using Selenium, Appium and JavaScript unit testing frameworks.
https://saucelabs.com/

How setup selenium firefox tests on CodeShip?

Intro
Hi, I'm developing rails application, which use capybara, selenium-webdriver and rspec for tests.
Problem
Now I have a functional tests, which runs in firefox (default selenium browser) and works with redirects to other hosts. For example, rspec before hook to get fresh google access token.
Locally on my laptop all tests runs with success:
bundle exec rspec
But codeship's builds fails.
Questions
Do I need to setup codeship to support "firefox" tests? If yes, how can I do it?
Does codeship supports redirects to other hosts?
Thanks!
Codeship supports running selenium tests in the CI , you can find more info here https://documentation.codeship.com/continuous-integration/browser-testing/
However when i tried to run the selenium tests in CI , chrome failed to start 90% of the times , so i am planning to spin up a selenium grid elsewhere and run the tests in codeship

Resources