Introduction to Selenium – Web Based Automated Testing with Selenium

Testing has become a more decisive segment in SDLC. It is the process which consists of the static and dynamic activities of the software life cycle. These activities cover the planning, analysis, design, execution and reporting. In the world of the Internet, Automation testing is a very important aspect. It provides better quality & quantity work in small span of time. However tools cost can be quite high that many company’s cannot bear. So “Selenium” an open source web based testing tool was born. The motive of this paper is to make organisations aware of Selenium, an introduction to Selenium, how it works and workarounds for some Selenium Challenges.

 

Introduction to Selenium

Selenium is an open source functional automation tool for the web based application. It was developed by the “Thought Work” in 2004.It is a remarkable tool for functional software testing.

 

There are two versions of Selenium:

Selenium 1.0

It consists of below tool suite:

  1. Selenium IDE
  2. Selenium RC Client/ Server
  3. Selenium Grid

Selenium 2.0

It consists of below tool suite:

  1. Selenium IDE
  2. Selenium Server
  3. Selenium Grid

 

Why Selenium?

Below are a few reasons to use Selenium:

  • Cost effective: It is an open source tool.
  • Language: Supports many languages like Java, Ruby, and Python and C #.
  • Browser: Supports multiple browsers like IE, Mozilla, Opera, Chrome and Safari so can be used for cross browser testing and can be integrated easily to new launched browser.
  • Framework: Supports multiple frame -works like Junit, TestNG, Bromine, Nunit, Rspec which make the automation more robust and can developed own framework.
  • Operating System: Supports multiple operating systems like Windows, Apple, Linux and Android.
  • Time Saving: With the help of selenium grid, Parallel execution of the test cases can be done.

Selenium Implementation: Selenium has two versions, Selenium 1.0 and Selenium 2.0.Both the versions have common components.

 

Selenium IDE: Selenium IDE is plugin to Firefox so can be downloaded easily .Selenium ide is used for record and play back functionality, the default script is generated in html and can play back in html format only on Firefox. For starting the Selenium IDE navigate tools option present in menu bar of the Firefox and click on Selenium IDE option. By default ,Selenium IDE is in recording mode  and start  navigating the application on Firefox browser and perform the action ,all the actions are recorded  and can be seen parallel into  Selenium IDE.

There are two tabs present on it, “Table” & “Source “ .Under Source Tab HTML format  or code of the recording can be analysed and under “Table” tab, there are three columns :

  • Command: It shows the action going to perform like Click, enter etc.
  • Target: It is or objects property where the action is going to perform.
  • Value: Any input value is shown here.

 

Selenium IDE is also used to get the object properties of the application. There are some other tools through which object properties can be identified like Firebug, IE Developer tool, Fire finder and Chrome developer tool.

After completing the recording, Test case can be exported into different language by navigating option File>>Export Test case AS ,In similar way ,  multiple test cases can be recorded and exported as the Test suite.

The HTML code can also be converted directly to the different – different language without exporting the test case, click the option Options>>Format and select the language in which want to convert the test case.

In previous version of selenium-ide, conditional statements like while/for and parameterization cannot be done now it can be done by adding selenium ide extension however it is not that much robust so  make the Selenium more effective ,Selenium RC/Client is used.

Selenium RC Server: Selenium RC is jar file which provides the functionality to launch the selenium test scripts on different – different browsers; it gets all command from selenium client and executes the scripts .By default the server is run at 4444.

 

For running the selenium scripts ,Selenium RC sever is run through the command prompt,, navigate the path where selenium rc server jar file is present and run the command “java –jar  seleniumserver.jar “

Selenium Client Server: Selenium client is nothing just the jar files or say language through which enhancement of the scripts is done and send the request to selenium rc server. For running the scripts, selenium rc is run through the command prompt.

Selenium Grid: Selenium Grid is most important aspect of the selenium. With the help of this, parallel execution can be done on different – different platform with different browser. It saves the time and increases the scope of the testing and provides the quality software product.

Selenium 2.0: Selenium 2.0 is the updated version of Selenium 1.0, it is also known as the Selenium WebDriver. It is completely based on the object oriented API so supposed to be more robust and can support in better way for the web based testing. ,Selenium IDE & Selenium Grid are working in similar way as implemented in selenium 1.0 however  there is no need to run the selenium server for running the scripts. Selenium server is required when have to perform parallel execution through selenium grid or have to connect the remote machine.

WebDriver API makes the direct call to launch the browser using browser’s native call. For every browser, browser’s driver is present. Below is list for the same for Java.

  • Internet Explorer: WebDriver driver = new InternetExplorerDriver();
  • Firefox: FirefoxProfile profile = new FirefoxProfile();
  • Chrome : WebDriver driver = new ChromeDriver();
  • Opera : WebDriver driver = new OperaDriver();

Selenium WebDriver API also supports the Android and IOS operating system; It has separate API to interact with it.

 

Reporting: Reporting is very important aspect for testing, In Selenium, there is predefined framework like Junit, TestNG which generates the HTML reports and there are so many API through which customized report is generated. Selenium can integrate with test management tool like QC and Test link so report can be imported from these tools also.

Automation Framework: Automation framework is strategy for the automation, it provides the structured way for the automation for obtaining the quality work with quantity and effectiveness .There are many predefined framework in Selenium like Junit, TestNG, Nunit etc. however implementation of hybrid framework concept with any predefined framework make selenium more effective.

Keyword driven approach for selenium web driver is more effective because there are maximum 30 to 40 keywords which can be converted into the reusable function and can be used for testing any web based application.

Challenges and workaround: Selenium is for testing the web based applications so while doing web based testing, many times user has to interact with window component or window popup so selenium cannot automate that however Autoit is third party open source tool which can be used. At the run time, Objects are not identified with default ID or X-path than can use different xpath for the same object or different property like CSS, DOM, and Name etc.

Conclusion: Selenium is better option for the automation of the web based application. It can increase the scope of testing and provide more confidence to the customer.  As well as that Regression and Smoke testing time will be condensed. I hope you enjoyed my short introduction to Selenium and that you found it useful.

 

Acknowledgement:

Author Naveen Saxena gratefully acknowledges of his colleague and friends for consistently motivating to write the paper.

 If You are Having Problems with Selenium, check Out the How To Selenium Series

Reference:

About the Author

Naveen

Working as Test Lead having 6 year of experience in Software Testing and Passionate about providing the best quality applications to users that run seamless across family of devices. Have expertise in Setting up Testing COE – Functional and Automation Testing where have implemented the best practice through which can improve the quality product with less time. Expertise to play the role of a trusted advisor for customers & stakeholders and have managed testing teams, People Management and active member for hiring strong testing talent. Quick risk assessment, Business Analysis and knowledge of wide range of tool make more capable to provide the best solution to the customer and able to give the best project estimation Have drove on various testing tool:  Automation: Selenium, Appium, QTP, Sikuli, Eggplant, Work Certify  Test and Defect Management: QC, HPALM, Jira, Bugzilla  Business Analysis: Smart Draw and Microsoft Visio Award: Has been awarded as TOP 10 QA award 2012 by Silicon India Magazine. Exposure on the Domain with Projects: 1) Banking: CITI Bank USA 2) Retail :H&M Sweden ,Target, Australia 3) Hospitality: MGM USA 4) Travel and Tourism: Discover America USA 5) Telecom: Ripple Communication USA 6) Social Networking: Ripple Communication USA 7) Mobile: France Telecom