Python Programming – Introduction to Selenium
Software testing refers to a set of processes and procedures which help us identify whether the product at hand is getting built as per expectation or not. If we find any deviations we log them as defects, and in the subsequent releases we perform regression testing, retest the bugs, and eventually, we are able to release a build to the market with an acceptable bug list. These regression tests, which we have to perform with every release cycle, are mandatory as well as monotonous in nature, which makes them an ideal candidate for test automation.
There are many tools available in the market which allows us to automate our web applications, both commercial and open source. We have tools like UFT, RFT, Silk, Watir, Selenium, and others. Of these, Selenium, which is an open-source functional testing tool for web applications, is the most popular. In this chapter, we will introduce it.
- History of Selenium
- Benefits of Selenium
- Components of Selenium
- Architecture of Selenium
In this chapter, we are going to learn about Selenium as a test automation tool the reason for its popularity. We are also going to learn about the architecture of Selenium to understand how it executes tests on browsers.
History of Selenium
There are different tabs on this web page, let’s have a look at what each represents:
• Projects: This tab basically lists the four projects, which make the Selenium tool. The Selenium IDE, Selenium RC, Selenium WebDriver, and Selenium Grid. We will talk in detail about these components in the coming chapters.
• Download: This tab, lists the various download that is required while setting up our system for using the tool.
• Documentation: It provides detailed help that may be required to learn Selenium. It also provides code examples, in different programming languages, which Selenium supports. It is very well written and should be a one-stop solution for all Selenium-related queries.
• Support: The support page provides information on chat, user groups, and the organization that is providing commercial support for the Selenium tool.
• About: The about section talks about news, events, the history of Selenium, and how one can get involved in the Selenium activities.
Benefits of Selenium
Selenium is one of the most popular open-source functional test automation tools for web applications. The reason for its popularity is due to the following:
- It supports multiple programming languages. You can code in Java, C#, Python, Ruby, and Perl.
- It supports the automation of multiple browsers like IE, Firefox, Chrome, and Safari.
- It supports multiple operating systems like Windows, Mac, and Linux.
- It is available free of cost,
- It has a strong and active user community, which is very helpful.
Components of Selenium
Selenium is not a one-test automation tool, but a group of four different tools, which are listed as follows, along with their usage:
• Selenium IDE: It is a tool used for recording and playing back scripts. It currently supports both Firefox and Chrome browsers. You can procure the tool from this link: https:// www.seleniumhq.org/selenium-ide/
• Selenium RC: It was also known as Selenium 1.0. Although no longer supported, it was a combination of a selenium server and a client, which allowed automation of any browser on any operating system.
• SeleniumWebDriver: Also known as Selenium 2.0, whose 3.0 version is now available. It uses the technology of WebDriver API, where every browser has the capability through its API to automate itself. Currently, the Selenium versions are released through the WebDriver technique of browser automation.
• Selenium Grid: It uses a server component from the Selenium RC, and executes it in two different modes as hub and node. This allows the execution of multiple tests simultaneously, which saves time and cost.
Architecture of Selenium
The main component of Selenium which is used in projects for automation is the Selenium WebDriver. We are going to discuss its architecture, which has four main components, as follows:
- The client libraries available in different programming languages
- JSON wire protocol over HTTP for communication to send commands from client to server
- WebDriver for every browser
- Browsers: Chrome, Firefox, IE, Opera, and more
The following diagram shows the client libraries that are available in different programming languages. We create our scripts using them. These then send commands to the WebDriver server using the JSON wire protocol over HTTP. The WebDriver for each individual browser
receives these commands and automates the browser, performing the action on them, thus achieving the task at hand:
As we conclude this chapter, we understand the background of the test automation tool Selenium, its importance, and the reason behind its popularity in the test automation world. In our next chapter, we will be discussing a component of Selenium – the Selenium IDE.