Friday, August 3, 2012

How To Automate Testing using Selenium


What is Selenium ?


"Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language (Selenium IDE). It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including C#, Java, Groovy, Perl, PHP, Python and Ruby. The tests can then be run against most modern web browsers. Selenium deploys on Windows, Linux, and Macintosh platforms"  [ Reference: http://en.wikipedia.org/wiki/Selenium_(software) ]

Further you may refer the main web site of Selenium for more details.  [ http://seleniumhq.org/ ]


Selenium IDE



  • As a starting point, it would be nice to first setup Selenium IDE in your Firefox browser ( you can find the xpi from following url :  http://release.seleniumhq.org/selenium-ide/1.9.0/selenium-ide-1.9.0.xpi )
  • Using Selenium IDE you can simply records the steps that you do in the web site and then you can play back them easily. 
  • You may refer this article as a starting guide:  http://seleniumhq.org/docs/02_selenium_ide.html
  • Further you can add assertions to your scripts and verify the values and enhance you scripts.
  • But still if you wish to automate complex work flows in web sites using values from files, xml etc, it is recommended to move to Selenium RC using Java or any language you prefer to write test cases. But still Selenium IDE can used to record the basic flow and then Export to Java (or any supporting language) and then modify them and add more functionality using Java (or the supporting language)

Selenium RC

How to Start Test Automation using Java & Selenium RC

  • Make sure you have downloaded the Selenium Server jar file from above link
  • Record the script using Selenium IDE and export it to Java ( JUNIT )
  • Add the java file to your project
  • Add the Selenium Server jar file to your project as well 
  • Start the selenium server using the command line 
    • Go to the path of the jar file and type  java -jar <selenium server jar name>
  • Run the test case from your Java IDE (eg: inteliJ Idea, Eclipse )
  • You may refer this article for more details http://seleniumhq.org/docs/05_selenium_rc.html
In order to automate a data driven test case using files you may use different techniques to read files from java and then set the values to the relevant places. 

Example: How to read values from Excel files and use in Selenium Test Cases

Selenium Tips
Please refer following links for more tips 







6 comments:

  1. The blog gave me idea to automate testing using the selenium my sincere thanks for sharing this post and please continue to share this post
    Selenium Training in Chennai

    ReplyDelete