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

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Selenium with Python - A Beginner's Guide

Get started with Selenium using Python as a programming language

Pallavi R Sharma

Book details
Book preview
Table of contents
Citations

About This Book

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.


Description
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: http://5elementslearning.com
LinkedIn Profile: https://www.linkedin.com/in/pallavirsharma/

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Selenium with Python - A Beginner's Guide an online PDF/ePUB?
Yes, you can access Selenium with Python - A Beginner's Guide by Pallavi R Sharma in PDF and/or ePUB format, as well as other popular books in Informatik & Qualitätssicherung & Prüfung. We have over one million books available in our catalogue for you to explore.

Information

Year
2019
ISBN
9789389328813

CHAPTER 1

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.

Structure

  • History of Selenium
  • Benefits of Selenium
  • Components of Selenium
  • Architecture of Selenium

Objective

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 http://seleniumhq.org/, 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: 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 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

Conclusion

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.

Questions

  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?

CHAPTER 2

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 (https://github.com/seleniumHQ/selenium-ide/graphs/contributors) and brought back Selenium IDE. The current version supports both Firefox and Chrome browsers.

St...

Table of contents