Sujay Raghavendra
Dharwad, Karnataka, India
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-6248-1 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-6248-1 e-ISBN 978-1-4842-6249-8
https://doi.org/10.1007/978-1-4842-6249-8
Sujay Raghavendra 2021
Apress Standard
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, Suite 4600, New York, NY 10004-1562, USA. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Introduction
This book focuses on how to implement testing techniques using Selenium WebDriver with the Python programming language. This quick reference provides simple, functional test cases with a syntax-based approach for Selenium WebDriver.
Youll begin by reviewing the basics of Selenium WebDriver and its architectural design history. Next, you move on to the configuration and installation of the Selenium library in various web browsers, including the basic commands needed to start test scripts. Youll review keyboard and mouse action commands for testing user interactions on a web page and see how hyperlinks are tested.
The book examines various web elements using the eight different locators provided by Selenium to help you choose the one best suited to your needs. All Python scripts are real ready-to-test examples that are explained thoroughly in problem statements. Youll use different Python design patterns to automate test scripts that can be incorporated with Selenium.
Python Testing with Selenium teaches the expertise to write your own test cases.
About the Author
Sujay Raghavendra
works primarily in data science, machine/deep learning, and artificial intelligence. He is currently the Executive Director of Raghavendra Training & Consultancy (RTC), a startup company based in Dharwad, Karnataka, India. He co-founded RTC with Sumedh Raghavendra, his brother, in 2014. He plans and evaluates new technology projects in research and product development. His projects include analyzing a pap smear filter for microscopic medical images, thermal heat sensing in hospitals, OCR for handwritten characters, satellite image analysis, and network automation for maps, forecasting models, text analytics, predictions, and more.
Raghavendra is also a consultant on building research centers for technical universities and colleges. His recent interests include automating test cases through machine learning. He has published numerous research articles in international journals and has been on reviewer committees for various journals and conferences.
About the Technical Reviewer
Supreeth Chandrashekhar
is a seasoned software technology professional associated with Philips Healthcare, Bangalore. He has more than eight years of architect experience in building/running highly robust, massively scalable, and extremely secure systems, as well as setting up and managing mid-sized tech teams. He is extremely passionate about building great products that exceed customer expectations.
Sujay Raghavendra 2021
S. Raghavendra Python Testing with Selenium https://doi.org/10.1007/978-1-4842-6249-8_1
1. Introduction to Selenium
Sujay Raghavendra
(1)
Dharwad, Karnataka, India
Before Selenium , testing the functionality of a web application was done manually, which took many hours. The testing tended to rely on different scenarios. Each scenario was considered a test case to enact the behavior of the web app before its implementation. These test cases were deployed on various browsers to affirm any issues in the source code.
It requires a dedicated team of testers to check all test cases. Accuracy and time are major constraints in web development, which has led to automated test cases that can be used in different web applications without changing the source code. Selenium was developed to automate test cases.
This first chapter of the book offers a complete overview of Selenium and its core architectural design. The subtopics explain using Selenium and compares it to other testing tools in the domain. Later in the chapter, integrating Python with Selenium is explained. Lets start with a brief history and description of the Selenium tool and the reasons to use it.
What Is Selenium?
Selenium came into existence in 2004 at ThoughtWorks to test a web application named Time and Expenses by Jason Huggins. The tool was developed to test the front-end behavior of an application in various browsers. The tool was popular and open source. The increase in demand for automated testing led to the development of several versions of Selenium over the years, which are discussed next.
Selenium Tools and Versions
ThoughtWorks has released four major versions of Selenium to test web applications. Figure shows each version and its release year.
Figure 1-1
Selenium suite
Any one (or more) of these Selenium tools can be used by an organization; the choice depends on the test environments requirements. The first tool developed by ThoughtWorks was Selenium Core in 2004. It allowed the tester to write their own code/script to automate front-end interactions like keyboard or mouse activities. These activities were similar to a user interacting with the application.