Selenium with Python - A Beginner's Guide
eBook - ePub

Selenium with Python - A Beginner's Guide

Get started with Selenium using Python as a programming language

Pallavi R Sharma

  1. English
  2. ePUB (handyfreundlich)
  3. Über iOS und Android verfĂŒgbar
eBook - ePub

Selenium with Python - A Beginner's Guide

Get started with Selenium using Python as a programming language

Pallavi R Sharma

Angaben zum Buch

Über dieses Buch

Step by step directions to get started with Selenium using Python as a programming language. Key Features

  • Get introduced to the world of Selenium
  • Understand the concept of locators in Selenium
  • Learn how to write scripts using Selenium WebDriver in Python
  • Learn the concepts of synchronization
  • Learn how to handle different HTML elements like form, table, alert, frame, and dropdown
  • Learn about design patterns like the page object model, data-driven tests, and adding assertions.

Selenium is the most popular open source test automation tool available in the market. In the last decade, its usage has dramatically increased in the IT sector across all types of organizations. The reason for its popularity is mainly because it supports multiple programming languages, test executions on multiple browsers and operating systems. In this book, we will learn about the different components of Selenium. We will discuss the concepts of WebDriver and learn how to apply test automation concepts with it to automate the testing of our application. We will learn the process of recognizing the test objects on the screen and writing Selenium commands using Python as a programming languageWe will also discuss how to use design patterns like the page object mode and data-driven testing to ensure building a robust test framework, which is modular and scalable in nature. What You Will Learn
The objective is to introduce the world of Selenium to a manual tester who knows Python as a programming language. You will learn to demystify the concept of identifying test objects and writing Selenium commands to create robust test scripts. This book will help learn to automate different HTML elements, which we come across in the web applications we need to test. You will understand how to build a good test suite by learning the concept of design patterns like the page object model and data-driven tests to ensure maintainability of code. Who this book is for
This book is for people who have experience in manual testing and knowledge in Python as a programming language. This book will also be helpful for a developer who knows Python as a programming language and is looking for test automation as a career option. Table of Contents
1. Selenium - Important Conceptual Background
2. Selenium IDE
3. Locators in Selenium
4. Installation and Setup
5. Selenium WebDriver
6. Unit Test Creation n Python
7. Synchronizing Tests
8. Parameterization of Tests
9. Handling Different Web Elements
10. Working with Frames
11. Concept of the Page Object Model
12. Implementing Selenium Grid About the Author
Pallavi has an overall professional experience of 14 years. She has worked in varied roles as a product/project manager in the presales team and marketing team for solutions on test automation tools.She holds two provisional patents along with other contributors for her work on building tool agnostic test automation framework solutions. Currently, she is acting as a test automation coach, writer, speakerand owner at 5 Elements Learning where she collaborates and works with test automation enthusiasts across the globe. As an avid learner, she likes to keep herself updated to the latest trends andTechnologies. She is a firm believer in a larger good and likes to live by example.She volunteers her time for the organization eVidyaloka where she acts as a centre administrator. She is a lifetime member for the Jabarkhet forest reserve and People for Animals. Website:
LinkedIn Profile:

HĂ€ufig gestellte Fragen

Wie kann ich mein Abo kĂŒndigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kĂŒndigen“ – ganz einfach. Nachdem du gekĂŒndigt hast, bleibt deine Mitgliedschaft fĂŒr den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich BĂŒcher herunterladen?
Derzeit stehen all unsere auf MobilgerĂ€te reagierenden ePub-BĂŒcher zum Download ĂŒber die App zur VerfĂŒgung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die ĂŒbrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den AboplÀnen?
Mit beiden AboplÀnen erhÀltst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst fĂŒr LehrbĂŒcher, bei dem du fĂŒr weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhĂ€ltst. Mit ĂŒber 1 Million BĂŒchern zu ĂŒber 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
UnterstĂŒtzt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nÀchsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Selenium with Python - A Beginner's Guide als Online-PDF/ePub verfĂŒgbar?
Ja, du hast Zugang zu Selenium with Python - A Beginner's Guide von Pallavi R Sharma im PDF- und/oder ePub-Format sowie zu anderen beliebten BĂŒchern aus Informatique & Assurance qualitĂ© et tests. Aus unserem Katalog stehen dir ĂŒber 1 Million BĂŒcher zur VerfĂŒgung.



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 defect, 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

Selenium was created by Jason Huggins, while he was working at Thoughtworks in 2004. It was then called JavaScriptTestRunner. It was used to test an internal time and expense application. It was later released to the open source community as Selenium. It was named Selenium because it overcame the shortcomings of another competitor that was made by an organization Mercury. Selenium as a chemical is used to treat Mercury poisoning. The main website of Selenium is, which is shown in the following screenshot. Here, you will find all the information related to the Selenium tool:
Figure 1.1
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 downloadthat are 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, 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 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.
Figure 1.2

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:
  • Selenium RC: It was also known as Selenium 1.0. Although no longer supported, it was a combination of aSelenium 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 server component from the Selenium RC, and executes it in two different modes as hub and node. This allows executions 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:
Figure 1.3


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.


  1. Who created Selenium?
  2. Which Selenium component is used for record and playback?
  3. Why is Selenium popular?
  4. Which protocol does Selenium WebDriver use for communication?
  5. Is Selenium 1.0 still in use?


Selenium IDE

In this chapter, we will discussthe Selenium IDE component. This component allows us to record and playback our tests. It is an integral component of the Selenium project, and has been recently upgraded and brought back into function with the help of the organization Applitools.
Selenium IDE, also known as SIDE stands for Selenium Integrated Development Environment. It is one of the four projects of the Selenium ecosystem. The earlier version of Selenium IDE worked only on the Firefox browser. But the changes in the Firefox browser from version 55 didn’t allow Selenium IDE integration. At this juncture, Applitools helped Selenium community with a group of dedicated engineers ( and brought back Selenium IDE. The current version supports both Firefox and Chrome browsers.



  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. About the Author
  6. Reviewer
  7. Acknowledgement
  8. Preface
  9. Errata
  10. Table of Contents
  11. 1. Introduction to Selenium
  12. 2. Selenium IDE
  13. 3. Locators in Selenium
  14. 4. Installation and setup
  15. 5. Understanding WebDriver, WebElement and By
  16. 6. Unittest in Python
  17. 7. Synchronizing Test
  18. 8. Concept of Parameterization
  19. 9. Working with Different WebElements
  20. 10. Frames, Alerts, and Action Class
  21. 11. Page Object Model
  22. 12. Selenium-Grid