What is Selenium?
Selenium is a tool that automates browsers and the purpose to automate web browsers is to test them. Major browser vendors have begun to take selenium as part of its core.
It is impossible to estimate the role of web applications in our lives; many of the applications are being used online, as is the case of CRM and ERP.
Therefore it is important to put the effort in testing web applications. There are many tools for automation but Selenium is recommended because:
- It’s free!
- It evolves and grow
- There are different ways to make and run test cases: record and run using Selenium IDE, Record and run using cubic test, record, refactor and run using Java IDE, Use Selenium Core, web Driver or Selenium Grid to run your tests etc.
- Recorded test cases from Selenium IDE can be translated to different programming languages: Java, Ruby, PHP, .NET, Pearl and Python
- It supports a lot of platform and browsers
Main Selenium components are:
- Selenium IDE is a Firefox add-on and this makes it easy to record and run tests in firefox 2 onwards. It is possible to generate codes to run and test with selenium Remote Control.
- Selenium Grid uses selenium remote control pen to another level with multiple servers with multiple operating systems or browsers.
- CubicTest is a graphical Eclipse plug-in for writing Selenium and Watir tests.
- Bromine is a tool that makes it easier for QA corer and watch Selenium RC test results.
- Selenium on Rails provides an easy way to test Rails application with Selenium Core. Suite files are created on the fly for each directory and the Selenium Core files don’t have to pollute /public.
- Selenium on Ruby is the hub for newer Ruby related Selenium projects.
Selenium just uses two tools to automate web application test case to record it, they are Selenium IDE and Firefox.
This part of the document will be shown as an example of how a test is recorded to automate.
- Start Selenium IDE and start Selenium IDE Option Recording.
- Type and introduce www.google.com in address bar (Just for example).
- Type Selenium into the search field and click Search, (Don't press the Enter button because Selenium IDE does not recognize it). And click with the right button, select Verify Text Present in Selenium.org.
- Stop Recording.
To run the test case that we just created, we have two options. The first is using Selenium IDE. The second is using Selenium Test Runner. First we will explain how to run the test case with Selenium IDE.
To run the test case in Selenium Click "Play current Test Case" button to run and in most cases it will fail because the page has not loaded enough and the body of the text was not received and analyzed. To solve this, "Insert new command" and it is selected in the context menu.
Target = "30000" means having to wait until the page is loaded but no more than 30 seconds.
The second option is using "Selenium Test Runner". The main difference is that when we click to run or play in the "Test Runner" it can give us more information about the test cases as the time is spent and the return results of the tests in a single window.
You can transform test script to different programming languages and this is done as follows: Option > Menu> Select Format and choose suitable format.
Export Scripts Test can be run from outside using Selenium IDE Selenium RC, in this case Java can run on eclipse.
In conclusion, we can say that Selenium is a comprehensive, easy to use and in addition to its versatility it gives you the tool to export the code to other compilers. Last but not least, the tool is free so it makes it affordable and puts it among the main tools for web development.
About the Author
Alberto Chavez is a QA engineer with 5+ years of experience. He likes to design test cases and set environments to test software for web and mobile applications for several client projects across many different verticals. He currently works at iTexico as a QA Engineer.