Friday, December 6, 2013

Test Automation Using Selenium !!

Hello everyone !! 


Recently Me and my colleague Mr. Vinod Krishnan realised the need of a platform where all real time problems can be discussed which intern help our testers in solving the problems as well as enhancing their knowledge. 

This forum is going to be beneficial for guys who are involved in software testing. I'll be posting topics which may be very useful not only for automation guys but also for manual testers !! You may throw your problems here and we'll try to find solution for them. I'll try to publish maximum information or at least the revenant URLs. Our main focus will be on real time problems which we face during our automation implementation.


Prerequisite for Automation:

1. Before going into any kind of automation in terms of testing, few points to remember:
  • Do you actually need any kind of automation.
  • If yes then where you are going to use it.
  • What kind of tool you'll be using like freeware, licensed etc.. 
  • if freeware, then which tool you require, always analyse the language capability of the tester. 
  • How frequently the automated scripts will be used.
  • How dynamic are the changes being thrown into test application.  

2. After you conclude that you can not avoid test automation and you have to use some tool, then understand automation.

3. Test Automation can be achieved by some simple code written in Python, VB Script, JAVA or Java Script, Batch files or may be some macro like iMacro ( for Browser level automation ) etc… so before you opt for any automation tool, always see if any of the above can serve your purpose.

4. Once you are through to all the above analysis and you've decided to go for some tool and if that is Selenium, then we'll plan each step right from the installation to write the first test. Most common language of writing code in Selenium is Core JAVA, so before you jump onto Selenium, refresh your Core Java and OOPS knowledge. Its simple and interesting to learn.

Here is the link which has basic tutorial for beginners, please take a look at it.

http://www.javatutorialhub.com/java-tutorial.html

5. Lets talk little about Selenium. Selenium supports these languages - Java, Python, Ruby, C#, PHP, Perl and these Browsers - Mozilla Firefox (inbuilt support), Internet Explorer, Google Chrome, Safari etc. Selenium has three components -
  • Selenium IDE - IDE is a plugin supported by only Mozilla Firefox. Using this plugin, you can record your actions and play them back. See the below URL for detailed installation and use of IDE. This part of Selenium is not used or maybe used by 1 % in IT Industry because of its limitation in features like - lack of data driven testing by using some excel sheets, mouse clicks, etc...
http://www.guru99.com/install-selenuim-ide.html
  • Selenium WebDriver - This component is an improved version of Selenium Remote Control or RC. Selenium RC is depreciated now because of a third party involvement between Browser and  automated scripts. Selenium WebDriver interacts Browser directly eliminating any intermediates.  We'll be discussing Selenium WebDriver primarily. 
  • Selenium Grid - Selenium Grid allows the Selenium WebDriver code to run simultaneously into various machines at the same time. Mainly Selenium Grid is useful in Browser Compatibility Testing which very common and frequent now a days. 
6. Selenium doesn't have any UI so you can't record your action and play them back. You've to write code in Core Java like a developer. To achieve this you need an Integrated Development Environment where you can write your code and run your automation script. Eclipse Juno is a popular and easily available tool or IDE.

7. Here is the URL which has the detailed information along with screenshots to install Eclipse and configure Selenium WebDriver into it. Remember Selenium WebDriver is a collection of Java - Jar files which you need to add in your project, see the detailed description at this URL -

http://www.guru99.com/installing-selenium-webdriver.html  


Baby Steps For Automation:

Any code irrespective of development or testing should be reusable. There should be minimum effort to be applied to maintain the code. To achieve this, we develop Framework. There are lot of framework available in market with lot of annotations which can be directly used in your test code. Some of widely used frameworks are - TestNG, JUNIT, Robitium etc.

We'll be discussing more about TestNG framework, its an improved version of JUNIT framework.

Steps:

1. Test Data:
  • First thing to see if test will be data driven and if yes then how the data will be stored or used for implementation.
  • Microsoft Spreadsheet is widely used for maintaining the data.

2. Coding:
  • Utilise the code or break the code into small functions so that the code can be utilised wherever required.

3. Reporting:
  • How the results will be reported to end user may be some client. For sharing results, we'll be using ReportNG framework, which will be explained little later.