My First Sip With Ruby on Rails Automated Testing

1 min read

Hi folks, here I am going to share a few points about my experience in Automated software testing.
My project is a web app based on Ruby on Rails.
I started with selenium test cases to test the application. I used selenium IDE and recorded few test cases and exported it to RSpec, Ruby . As the test cases grow,I find it difficult to run the specs as it was time consuming and need to wait for a long time to run the entire test cases. As per the suggestions of my team mates, I have switched over to capybara making selenium as a default driver by adding the following command in spec_helper.rb
Selenium Web-driver is designed to provide a simpler, more concise programming interface. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application.
[source]
Capybara.default driver = :selenium
[/source]
 
I included capybara and selenium web driver gems in gemfile to run my specs
[source]
gem capybara
gem selenium-webdriver
[/source]
One main problem I faced, while testing the application is that it was not detecting the name of the user in the top right corner of the web app in my project. This was due to the screen size of application. The window size is not maximized by default.
So the test case was failed in this scenario.Finally the issue is solved by maximizing the window size of the browser. This can be obtained by simply
adding this to your spec_helper.
[source]
before :each
Capybara.page.driver.browser.manage.window.maximize
end
[/source]
I also tried running the test cases in headless browser for more speed. I installed qt driver to run the tests in capybara-webkit. The below mentioned link is a good reference to install qt driver.

https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit

To my surprise, it takes less than a minute to run more than 30 test cases.
I personally feel, to start with automation testing (Integration Testing), selenium is one of the best choice and we can move to capybara as the next level once we are familiar with selenium.
I also got this test cases running along unit tests on a Continuous Integration server (Circle CI). The results were encouraging me to write both pass and failing test cases.
I will share more of my thoughts and useful tips as I progress with it.

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *