Google+

Different Components in Selenium Test Automation Tool

Selenium Tools Set


Selenium is not a single tool, instead it is a set of tools. The below are the four different tools which we together call as Selenium:

  • Selenium IDE
  • Selenium RC
  • Selenium WebDriver
  • Selenium Grid


We can also call these tools set as Selenium components. Its not mandatory to use all these components to automate applications, instead we select them for automation based on our Applications requirement. 


Selenium IDE


Selenium IDE is a 'Record and Playback' tool and is available for us to use in the form of a Firefox Add-on. So, before understanding the Selenium IDE, we have to first know about 'Record and Playback' tools.

In simple terms, Record and Playback tools are used to automate any application by recording the tests and playing back the recorded tests:

Recording the tests

  • Recording the tests is just like recording a video using cellphone
  • Recording in 'Record & Playback' tool is performed to create automated tests
  • Practically speaking 'Record' option of 'Record & Playback' tool will be turned on and then the activities performed on the Application which is displayed in a browser will be recorded until the 'Record' option is turned off.

Playing the recorded tests

  • Playback is just like playing the recorded video
  • Playback in 'Record & Playback' tool is performed to execute the recorded automated tests
  • Practically speaking 'Play' option of 'Record & Playback' tool will be selected to execute the recorded automated tests

Advantages of using 'Record & Playback' tools

  • Very easy for Automating the Tests - Can be used by the non programmers as programming knowledge is not required for using 'Record & Playback' tools
  • Takes less time for Automating the Tests - It wont take much time to automate the tests using 'Record & Playback' tool, as we simply record the application actions over browser and later execute the recorded actions using play options.
  • Suitable for less complex projects - 'Record & Playback' tools are very useful for automating the projects whose complexity is less, as the creation of automation tests will be easy and the time taken to automate the tests will be less when compared to other ways.

Disadvantages of using 'Record & Playback' tools

  • Automation scripts maintenance is more - When any buttons or links or UI changes in the application, we need to re-record all the earlier recorded automation tests which are getting impacted due to the changes. i.e. We need to use 'Record & Playback' tool to re-record all the impacted automation tests. But when we use programming for creating automation scripts, this maintenance will be reduced, as we will update the changes in a single file in the automation framework to which all the tests will refer, instead of editing the changes in all the automation tests which got impacted by these changes. Hence, even though the creation of automation scripts using 'Record & Playback' tool is easy,  the maintenance of the recorded scripts will be high.
  • Re-usability will be less - If we want to automate 100 tests, where all the tests needs to be performed after logging into the application, then using 'Record and Playback' tool we need to record login functionality for all the 100 tests separately. But if we use programing for automating tests instead of ‘Record and Playback’ tool, then as part of framework we can have a single file where we can keep the reusable code for login functionality and use the same reusable code with the 100 tests. Hence the re-usability will be less in case of automating the tests using ‘Record and Playback’ tool.
  • Not suitable for complex applications - Due to the maintenance and re-usability problems in ‘Record and Playback’ tools, automating the test cases for complex Application is not recommended. As complex applications contains huge list of tests and it will be difficult to     re-record the huge list of tests when anything changes in the application. And also due the huge list of scenarios, the scope for re-usability will increase. Hence ‘Record and Playback’ tools are not suitable for complex applications.  

Selenium IDE

Selenium IDE as mentioned earlier is a ‘Record and Playback’ tool and is one of the 4 components of Selenium. Selenium IDE is provided by Firefox in the form of an Add-on / Plug-in and is free to install on your Firefox browser.

"As part of learning Selenium IDE, the basic understanding of using Selenium IDE is enough and is not required to learn in detail."

As you have now understood the usage of ‘Record and Playback’ tool, the following are the different posts using which you can explore the functioning of ‘Selenium IDE’:


Hence Selenium IDE is a ‘Recording and Playback’ tool and is useful for creating automation tests for simpler applications in an easiest and fastest way. And no programming language is required for using this tool.


Selenium RC


Selenium RC used to be the leader in the market for a long period of time until Selenium WebDriver is introduced into the market in 2006. Understanding Selenium RC will help us in understanding the power of the latest Selenium WebDriver. Selenium RC stands for Selenium Remote Control and is nothing but an API. Before understanding Selenium RC, we have to first understand the term API.

API stands for Application Programming Interface. API in simple terms is nothing but a group of functions and wont have any Graphical User Interface. Selenium RC is also an API and has its own set of functions which help us in automating the applications. For example, Selenium RC’s API has a function called click( ), which will help us clicking on the GUI elements on the Web Applications say Buttons, Links etc. Selenium guys did all the hard work and have already written the code for the functioning of methods like click( ) and provided them in the form of an API. We just need to use the click( ) method from the API on the GUI elements like Buttons and Links, to perform operations on them as part of Selenium Automation.

But Selenium RC is an outdated now, almost all projects now moved to a new API known as WebDriver. Since WebDriver API is the latest API of Selenium, we can simply ignore using Selenium RC. Even though Selenium RC is outdated, the below details of Selenium RC are explained for General Knowledge sake.

Server is required for executing the automation scripts 

Selenium Remote Control Server is required for executing the automation scripts as shown below:


Selenium RC Server acts as the middle man between ‘Selenium RC Automation Scripts’ and the Browser as explained below:

  • Need to launch ‘Selenium RC Server’, as Selenium RC Server acts as the middle man between ‘Selenium RC Automation Scripts’ and the Browser. On executing the ‘Selenium RC Automation Scripts’, ’Selenium RC Server’ first injects a JavaScript program called Selenium Core into the browser. Once the Selenium Core is injected into the Browser by ‘Selenium RC Server’, Selenium Core injected into the browser will start receiving instructions by ‘Selenium RC Server’ from your test program. On receiving the     instructions, Selenium Core will execute the instructions on the residing browser using the JavaScript commands. The browser will accept the instructions from Selenium core and the response of the executed instructions will be received by Selenium RC Server. Selenium RC Server will receive the responses of the browser and then displays the results. Selenium RC Server will then fetch the next instructions from the Automation scripts and repeats the same cycle. The below diagram depicts the same.


Selenium WebDriver


Selenium WebDriver is introduced in 2006 and is the latest leader in the market. Selenium WebDriver is nothing but an API. Before understanding Selenium WebDriver, we have to first understand the term API. 

API stands for Application Programming Interface. API in simple terms is nothing but a group of functions and wont have any Graphical User Interface. Selenium WebDriver is also an API and has its own set of functions which help us in automating the applications. For example, Selenium WebDriver’s API has a function called click( ), which will help us clicking on the GUI elements on the Web Applications say Buttons, Links etc. Selenium guys did all the hard work and have already written the code for the functioning of methods like click( ) and provided them in the form of an API. We just need to use the click( ) method from the API on the GUI elements like Buttons and Links, to perform operations on them as part of Selenium Automation.
The older API of Selenium i.e. Selenium RC is an outdated now, almost all projects now moved to a new API known as WebDriver. Since WebDriver API is the latest API of Selenium, we can simply ignore Selenium RC. 

Advantages of Selenium WebDriver over Selenium RC
  • Server is not required for executing the automation scripts
  • Supports Android and iPhone testing
  • Interacts natively with the applications running over supported browsers
  • Has complex and large API
  • API’s are fully object oriented
  • Supports moving mouse cursors
  • Simpler Architecture
  • Faster, as it directly speaks to the browsers
  • Realistic interaction with GUI elements (For example, wont enter text into the disabled textbox)
  • Simpler, as it wont contain duplicate and confusing commands
  • Supports headless browsers like HTMLUnit, PhantomJS etc. 

Selenium WebDriver interacts natively with the Browsers and hence wont require proxy server as a mediator:

Selenium WebDriver interacts with the browsers directly without requiring proxy server as shown below:


Conclusion

Selenium WebDriver is the latest API of Selenium and has successfully replaced the outdated Selenium RC API. The main advantage of Selenium WebDriver is that is natively interacts with the browsers and hence wont require any proxy server as a mediator for executing the automation scripts. 


Selenium Grid


Selenium Grid is neither a tool having GUI, nor an API like Selenium RC / WebDriver. Instead Selenium Grid is just a concept, which will allow us to distribute the multiple tests across multiple machines, multiple Operating Systems and multiple browsers for execution.

Selenium Grid speed up the execution process when there are huge number of tests. i.e. Huge list of tests will be distributed across multiple machines and executed at the same time for reducing the execution time. For example, if one test is executing on machine1, at the same time another test will get executed on machine2. 

Example: Lets say, we have 10 tests where each test takes 1 minute each. If you are not using Selenium Grid, then one test will be executed after another in the same machine and hence takes 10 minutes of time for executing 10 tests. But if we use Selenium Grid to distribute these tests across 5 machines, then 5 tests will be executed at the same time and hence it takes only 2 minutes for executing all the 10 tests. 

Hub and Nodes

Using Hub and Nodes concept, Selenium Grid will distribute the tests across multiple machines, operating systems and browsers. Selenium Grid uses Hub as the central machine and uses it to distribute the tests for execution across multiple machines which are knows as Nodes. The below diagram depicts how Selenium Grid uses Hub and Nodes concept to distribute the tests across multiple machines, OS and browsers:




Versions of Selenium Grid

Selenium Grid has the two versions i.e. Selenium Grid 1 and Selenium Grid 2. Selenium Grid 1 can be used with the outdated Selenium RC and hence Selenium Grid 1 can be ignored. Selenium Grid 2 can be used with the latest Selenium WebDriver and hence it is the latest Selenium Grid version used in the market. 

Conclusion

Selenium Grid is a concept using which we can define multiple machines as Hub & Nodes, and distribute the tests across multiple machines, operating systems and browsers. The purpose of Selenium Grid is to run multiple tests simultaneously across multiple machines to reduce execution time of tests.  

No comments: