===== Automated Testing Using Selenium (Draft) =====
===== Requirement =====
== 1) Post deployment testing ==
Should be able to run a set of predefined test cases after every deployment to make sure that basic app flow works fine.
== 2) Acceptance testing ==
Make sure the functionality does not break wrt to UI and pages after every checkin of the developer. This is to be done by running the defined test cases with each checkin as part of continuous integration build (using cruise control for now).
The test cases are to be prepared majorly by recording them and making minor changes needed with minimal effort.
===== Implementation =====
== a) Recording and preparing test cases ==
Recording of test cases are done through Selenium IDE only on Firefox.
Further the recording is only needed,whenever we are adding any new scenario or
feature or modifying any scenario.
Tools Required -
* Selenum IDE 2.5.0
* Firefox
Demo -
{{:selenium_recording_testcase.zip|}}
== b) Post Deployment Testing ==
Recorded test cases in point a) will be exported as HTML and saved as test suites.
They will be either ran through Selenium IDE or Selenium RC server after each
deployment.
1) Selenium IDE - Test cases can be easily modified and run,but we can’t do
cross-browser testing through it. For now, only supported on Firefox. This is the referred method to start the implementation for learnexa app.
2) Selenium RC server - Test cases can be run in different browsers,but we need to
provide some explicit wait in each test case after every command. This is an open issue which we can solve and use this soon in the future.
Tools required -
* Selenium IDE and Firefox
Demo -
{{:selenium_running_testcase.zip|}}
* Selenium RC server “selenium-server-standalone-2.39.0.jar” for cross browser
testing.
**Open Issue -**
Before running the test cases through Selenium RC server,we have to provide
some explicit wait before each command in test cases. This needs to be cleanly fixed to use RC server extensively.
//So right now we are staying with Selenium IDE,unless we find some solution for it.//
== c) Acceptance Testing ==
Test cases are recorded as in point a) by running a local learnexa app server. They are exported as ruby scripts. These are again ran as a test suit in the continuous integration server using a rake task whenever any code change is checked in.
A rails plugin “Selenium-On-Rails” is used to have this test suit and each test case is saved in the form of a .rsel script. These test cases need to be changed by developers or qa according to the new added features or any modified scenario.
Tools required -
* Learnexa app local setup in test environment
* Selenium On Rails plugin(http://railscasts.com/episodes/116-selenium)
===== Setup Instructions =====
== a) Post Deployment testing ==
1) Download the Selenium IDE from the following link - http://docs.seleniumhq.org/download/
2) Open the the IDE, record the test cases and save them.
3) Run the test case through Selenium IDE in firefox.
4) Add Plugins -
- Download following plugin to put some implicit wait for an element to be present while running the test cases - https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-implicit-wait/
- Download following plugin to highlight a particular element being clicked or focussed while running the test cases - https://addons.mozilla.org/en-US/firefox/addon/highlight-elements-selenium-id/
- Download following plugin to save the results of the test execution for the test suite - https://addons.mozilla.org/en-US/firefox/addon/test-results-selenium-ide/
- 5) Run the HTML test suites through RC server for crossbrowser testing
- - RC server can be installed from - http://docs.seleniumhq.org/download/
- 6) By doing this we can verify the site functionalities after the deployments.
5) Install Selenium Webdriver using following command -
gem install selenium-webdriver
6) Install chromedriver for running test cases in chrome browser.
7) Export the test cases in ruby language.
8) Run the test case in terminal using the following command "ruby ".
== b) Acceptance testing ==
1) Install the Selenium On Rails plugin
- Located at - http://railscasts.com/episodes/116-selenium
- Source code located at - https://github.com/ryanb/railscasts-episodes/tree/master/episode-116
- Reference - https://github.com/paytonrules/selenium-on-rails/blob/master/README.m
2) Setup the application in local
3) Start server,Record and save the test cases in Selenium IDE
4) Export them in ruby language.
5) Convert them in Rselence(.rsel) code and save them.
6) Run the test cases as a rake task after starting the server. \\ By following above method,we can verify the site functionalities after developer's checkins.
===== Running Automated Test Cases =====
1) Login to the Ubuntu(192.168.2.182) machine with the following username: parleer
2) Open terminal and go to the following directory "home/Webdriver_Chrome" or "home/Webdriver_Firefox"
3) All test case files will be present in this directory, run it using the following command "ruby "