100% found this document useful (1 vote)
18 views

[Ebooks PDF] download Selenium Fundamentals Speed up your internal testing by automating user interaction with browsers and web applications 1st Edition Diego Molina full chapters

Diego

Uploaded by

gerusecordya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
18 views

[Ebooks PDF] download Selenium Fundamentals Speed up your internal testing by automating user interaction with browsers and web applications 1st Edition Diego Molina full chapters

Diego

Uploaded by

gerusecordya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Selenium Fundamentals Speed up your internal


testing by automating user interaction with
browsers and web applications 1st Edition Diego
Molina
https://textbookfull.com/product/selenium-fundamentals-
speed-up-your-internal-testing-by-automating-user-
interaction-with-browsers-and-web-applications-1st-edition-
diego-molina/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Selenium Essentials : get to grips with automated web


testing with the amazing power of Selenium WebDriver First
Edition Sams
https://textbookfull.com/product/selenium-essentials-get-to-grips-
with-automated-web-testing-with-the-amazing-power-of-selenium-
webdriver-first-edition-sams/
textboxfull.com

Python Testing with Selenium: Learn to Implement Different


Testing Techniques Using the Selenium WebDriver Sujay
Raghavendra
https://textbookfull.com/product/python-testing-with-selenium-learn-
to-implement-different-testing-techniques-using-the-selenium-
webdriver-sujay-raghavendra/
textboxfull.com

Web API Cookbook Level Up Your JavaScript Applications Joe


Attardi

https://textbookfull.com/product/web-api-cookbook-level-up-your-
javascript-applications-joe-attardi/

textboxfull.com

Supercritical Antisolvent Precipitation Process


Fundamentals Applications and Perspectives Diego T. Santos

https://textbookfull.com/product/supercritical-antisolvent-
precipitation-process-fundamentals-applications-and-perspectives-
diego-t-santos/
textboxfull.com
Selenium WebDriver Recipes in C#: Practical Testing
Solutions for Selenium WebDriver 3rd Edition Courtney Zhan

https://textbookfull.com/product/selenium-webdriver-recipes-in-c-
practical-testing-solutions-for-selenium-webdriver-3rd-edition-
courtney-zhan/
textboxfull.com

Performance Testing with JMeter 3 Enhance the performance


of your web application 3rd Edition Bayo Erinle

https://textbookfull.com/product/performance-testing-with-
jmeter-3-enhance-the-performance-of-your-web-application-3rd-edition-
bayo-erinle/
textboxfull.com

Getting Started with Varnish Cache Accelerate Your Web


Applications 1st Edition Thijs Feryn

https://textbookfull.com/product/getting-started-with-varnish-cache-
accelerate-your-web-applications-1st-edition-thijs-feryn/

textboxfull.com

Jump Start CoffeeScript Get Up to Speed With CoffeeScript


in a Weekend 1st Edition Castledine Earle

https://textbookfull.com/product/jump-start-coffeescript-get-up-to-
speed-with-coffeescript-in-a-weekend-1st-edition-castledine-earle/

textboxfull.com

Practical Web Penetration Testing Secure Web Applications


Using Burp Suite Nmap Metasploit and More 1st Edition Gus
Khawaja
https://textbookfull.com/product/practical-web-penetration-testing-
secure-web-applications-using-burp-suite-nmap-metasploit-and-more-1st-
edition-gus-khawaja/
textboxfull.com
Selenium Fundamentals

Speed up your internal testing by automating user interaction with


browsers and web applications
Diego Molina
BIRMINGHAM - MUMBAI
Selenium Fundamentals
Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any
form or by any means, without the prior written permission of the publisher, except in the case of brief
quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express or implied.
Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages
caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the
accuracy of this information.

Acquisitions Editors: Aditya Date


Content Development Editor: Edwin Moses, Aritro Ghosh
Production Coordinator: Samita Warang
First Published: September 2018
Production Reference: 1291018

Published by Packt Publishing Ltd.


Livery Place, 35 Livery Street
Birmingham, B3 2PB, U.K.
ISBN 978-1-78980-381-5

www.packtpub.com
mapt.io

Mapt is an online digital library that gives you full access to over
5,000 books and videos, as well as industry leading tools to help you
plan your personal development and advance your career. For more
information, please visit our website.
Why Subscribe?
Spend less time learning and more time coding with practical
eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content


Packt.com
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to the
eBook version at www.packt.com and as a print book customer, you are
entitled to a discount on the eBook copy. Get in touch with us at
customercare@packtpub.com for more details.

At www.packt.com, you can also read a collection of free technical


articles, sign up for a range of free newsletters, and receive
exclusive discounts and offers on Packt books and eBooks.
About the Author
Diego Molina is a software engineer in Test, specialized in testing
tool development, advising, and training teams how to test better.
He worked initially as a software developer for 8 years before
switching completely to testing, where he has been during the last 7
years. He is one of the maintainers of the official Docker-Selenium
project and a Selenium contributor.

He also co-created Zalenium, a dynamic, ready to use Selenium Grid.


He spends most of his time working with different teams and finding
ways to do UI testing in a more simple way. Additionally, he is often
attending the Selenium conferences, either presenting or
collaborating with the on-site workshops. You can find him often in
the IRC/Slack channel for Selenium.
Packt Is Searching for
Authors Like You
If you're interested in becoming an author for Packt, please visit autho
rs.packtpub.com and apply today. We have worked with thousands of

developers and tech professionals, just like you, to help them share
their insight with the global tech community. You can make a
general application, apply for a specific hot topic that we are
recruiting an author for, or submit your own idea.
Table of Contents
Title Page

Copyright and Credits

Selenium Fundamentals

Packt Upsell

Why Subscribe?

Packt.com

Contributors

About the Author

Packt Is Searching for Authors Like You

Preface
Who This Book Is For

What This Book Covers

To Get the Most out of This Book

Download the Example Code Files

Conventions Used

Get in Touch

Reviews

1. Getting Started

Software Automation

Going the Automation Way

Activity: Automation Brainstorming

Selenium Overview

The WebDriver API

The Selenium Server


Selenium Glossary

Activity: Selenium Planning

Environment Configuration

Browser Drivers

Downloading and preparing browser drivers

Maven Project

Creating a Maven project


Verifying That the Development Environment Is Ready

Summary

2. WebDriver Functionality

Instantiating a WebDriver – Chrome

Creating the Main Structure of Your First Selenium Automation Script

An Overview of Frequently Used Methods

Activity: Starting and Finalizing a Script

Controlling the Browser Window

Navigation

Navigating in an Automation Script

Resizing

Resizing Windows in an Automation Script

Managing Alerts

Managing Alerts in an Automation Script

Managing Frames and iFrames

Managing Frames in an Automation Script

Managing Windows

Managing Windows in an Automation Script

Activity: Resizing and Moving Windows with a Selenium Automation Scr

ipt

Summary

3. WebElement Functionality

Using Browser Developer Tools – Chrome


Inspecting a Web Page with Chrome Devtools

Overview of WebElement Functionality


Handling the StaleElementReferenceException

Interacting with Elements on a Page


Interacting with Textboxes and Textareas Elements

Interacting with Textboxes and Textareas During an Automation


Script

Interacting with Dropdown and Lists


Interacting with Dropdown and Lists During an Automation Scrip

t
Interacting with Radio Buttons and Radio Button Groups

Interacting with Radio Buttons and Radio Buttons Groups During


an Automation Script
Interacting with Checkboxes
Interacting with Checkboxes During an Automation Script

Activity: Filling in a Form and Submitting it


Element Locator Types – ID, Names, XPath, CSS, and So On

Activity: Locating Elements


Summary

4. Advanced Element Location


Navigating the DOM

Understanding the DOM's Structure


The Relationship between Selenium and the DOM

Identifying Elements and Creating Locators for Dom Elements


Retrieve Information from a Table

Searching Within Previously Found Elements


Locating Elements Based on Their Relationships

Searching for Elements Through Known Elements


Creating Complex Locators to Reach Any Element

Common Ways to Use CSS Selectors


Finding Elements by Using Class Attributes and IDs

Locating Elements by Their Attributes


Creating Complex Selectors for Unique Locators

Activity: Automating Checkout


Summary

5. Waiting for Elements


Implicit Waits

Creating an Implicit Wait


Explicit Waits

Activity: Creating an Explicit Wait


Implicit Versus Explicit Waits

Waiting for an Element with a Custom Written Condition


Creating Custom Waits for Finding Elements

Creating a Custom Wait (Waiting for an Element)


Creating Custom Waits so That an Element's Attribute Values Can Be U

pdated
Creating a Custom Wait (Waiting for an Element's Attribute Upd

ates)
Creating Custom Waits for an Element's Visibility
Creating a Custom Wait (Waiting for an Element's Visibility)
Summary

6. Page Object Model


Introduction to the Page Object Model

Understanding the Architecture of Web Applications


Applying Web Application Architecture to Test Automation Scripts
Modeling a Web Application Using Page Objects

Creating a Page Object


Creating a Page Object For Age Calculator
Creating an Automation Script
Creating an Automation Script for Age Calculator

Activity: Implementing the POM on a Multi-Page Application


Implementing Nested Page Object Instances
Activity: Implementing Nested Page Object Instances
Summary

7. Writing Tests
What is a Test Framework?
Choosing a Test Framework
Creating Test Scripts and Suites

Annotations
The TestNG.xml File
Activity: Creating a TestNG Test
Validating and Viewing Results

Activity: Viewing the Results


Summary
8. Analysis and Troubleshooting
Analyzing a Test Report

General Recommendations
Analyzing a Test Result
Tracking Down Timing Errors
How to Deal with Potential Timing Errors

Tracking Down Timing Errors with Synchronization Points


Separating Real Issues from Flaky Tests
Identifying Flaky Tests
Decreasing the Chances of Flaky Tests

Summary
9. Using a Selenium Grid
Configuring and Connecting to a Local Grid
Launching the Grid Hub

Verifying That the Grid Hub Is Running


Adding Selenium Nodes to the Grid Hub
Verifying That a Selenium Instance Has Been Registered

Activity: Running a Script Against a Grid Hub


Configuring and Connecting to a Network Grid
Adding Selenium Nodes Instances Running on Different Machines to the
Grid Hub

Activity: Creating a Small Selenium Grid with a Remote Node


Connecting to a Third-Party Service
Activity: Running a Test on a Third-party Service
Summary

Solutions
Chapter 1: Getting Started
Activity: Automation Brainstorming
Activity: Selenium Planning

Chapter 2: WebDriver Functionality


Activity: Starting and Finalizing a Script
Activity: Resizing and Moving Windows with a Selenium Automation Scr
ipt

Chapter 3: WebElement Functionality


Activity: Filling in a Form and Submitting It
Activity: Locating Elements
Chapter 4: Advanced Element Location

Activity: Automating Checkout


Chapter 5: Waiting for Elements
Activity: Creating an Explicit Wait
Chapter 6: Page Object Model

Activity: Implementing the POM on a Multi-Page Application


Activity: Implementing Nested Page Object Instances
Chapter 7: Writing Tests
Activity: Creating a TestNG Test

Chapter 9: Using a Selenium Grid


Activity: Running a Script Against a Grid Hub
Activity: Creating a Small Selenium Grid with a Remote Node
Activity: Running a Test on a Third-Party Service

Other Books You May Enjoy


Leave a Review - Let Other Readers Know What You Think
Preface
Automated testing is more efficient than manual testing, and more
and more industries in the IT sector are opting for automated tests
for applications, whether desktop or web.

Selenium is the most popular tool used to automate browsers, and


as it is currently on the path to become a W3C standard, its
importance in the testing world will only grow. Selenium is open
source, platform independent, and can be used to interact in a
programmatic way with web applications through any major vendor
browser (such as Google Chrome, Mozilla Firefox, Internet Explorer,
Safari, Microsoft Edge, and Opera).
Who This Book Is For
This book is designed for software quality assurance and
development personnel who want to learn how to automate browser
activity and web-based user interface tests with Selenium.
What This Book Covers
, Getting Started, deals with what automation is and why it is
Chapter 1

important. It then covers the how to use the Selenium WebDriver,


and then finally focuses on how to configure the development
environment for Selenium.

, WebDriver Functionality, takes you deeper into the details


Chapter 2

of Selenium, covering each of the main WebDriver class methods


and objects for the most commonly used browsers. Lastly, the
chapter focuses on how to open and manipulate a browser window
and navigate to a web page.

, WebElement Functionality, talks about how to use browser


Chapter 3

developer tools to review the code behind a web page and how to
find and interact with elements to later write and perform tests on
them.

, Advanced Element Function, covers how to navigate,


Chapter 4

search, and identify different elements in a web application by using


effective element locators.

Chapter 5, Waiting For Elements, trains the students on how to write a


stable automation script by waiting for an element to be present. It
discusses the differences between implicit and explicit waits, and
finally shows how to effectively synchronize a script in a custom
condition.

, Page Object Model, covers the principles behind Page


Chapter 6

Object Model, and how to model and implement an automation


script.

, Writing Tests, talks about test frameworks and how to


Chapter 7

choose them; as well as how to create test scripts and how to


validate results.

Chapter 8, Analysis and Troubleshooting, discusses the root cause of a


test failure by analyzing a test report, and tracking down errors It
also covers how to separate real issues from flaky tests.

, Using a Selenium Grid, focuses on how to configure and


Chapter 9

connect to the Selenium Local Grid, as well as the Selenium Network


Grid. Afterwards, covering how to connect to third party services.
To Get the Most out of This
Book
To complete this book successfully, students will require computer
systems with at least an Intel Core i5 processor or equivalent, 8 GB
RAM, and 4 GB available storage space. Along with this, you would
require the following software:

Operating System: Windows or above


Browser: Google Chrome (latest version)
Selenium WebDriver
Google ChromeDriver
IntelliJ IDEA
Download the Example Code
Files
You can download the example code files for this book from your
account at www.packt.com. If you purchased this book elsewhere, you
can visit www.packt.com/support and register to have the files emailed
directly to you.

You can download the code files by following these steps:

1. Log in or register at www.packt.com.


2. Select the SUPPORT tab.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box and follow the
onscreen instructions.

Once the file is downloaded, please make sure that you unzip or
extract the folder using the latest version of:

WinRAR/7-Zip for Windows


Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://githu
b.com/TrainingByPackt/Beginning-Selenium/tree/master/docs. In case there's an

update to the code, it will be updated on the existing GitHub


repository.

We also have other code bundles from our rich catalog of books and
videos available at https://github.com/PacktPublishing/. Check them out!
Conventions Used
There are a number of text conventions used throughout this book.

: Indicates code words in text, database table names, folder


CodeInText

names, filenames, file extensions, pathnames, dummy URLs, user


input, and Twitter handles. Here is an example: "The WebDriver class
provides constructors for each browser."

A block of code is set as follows:


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

When we wish to draw your attention to a particular part of a code


block, the relevant lines or items are set in bold:
private static void checkFrames(){

WebDriver driver = new ChromeDriver();

try {
driver.get("https://trainingbypackt.github.io/
Beginning-Selenium/lesson_2/exercise02_concept_04.html");

driver.switchTo().frame("info");

Bold: Indicates a new term, an important word, or words that you


see onscreen. For example, words in menus or dialog boxes appear
in the text like this. Here is an example: "If a user clicks on the Your
Account option on the Home Webpage, the application will check
whether they have already logged in."

Warnings or important notes appear like this.

Tips and tricks appear like this.


Get in Touch
Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this


book, mention the book title in the subject of your message
and email us at customercare@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy


of our content, mistakes do happen. If you have found a mistake in
this book, we would be grateful if you would report this to us. Please
visit www.packt.com/submit-errata, selecting your book, clicking on the
Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any
form on the Internet, we would be grateful if you would provide us
with the location address or website name. Please contact us at
copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic


that you have expertise in and you are interested in either writing or
contributing to a book, please visit authors.packtpub.com.
Reviews
Please leave a review. Once you have read and used this book, why
not leave a review on the site that you purchased it from? Potential
readers can then see and use your unbiased opinion to make
purchase decisions, we at Packt can understand what you think
about our products, and our authors can see your feedback on their
book. Thank you!

For more information about Packt, please visit packt.com .


Getting Started
The more robust and complex web applications get, the more robust
and complex the process of testing them becomes. As a crucial part
of software development, the testing phase must be as bulletproof
as possible, while also providing processes that simplify the
management and execution of tests. In this chapter, you will learn
what software automation is and how important it is to the
development cycle. You will be introduced to Selenium WebDriver,
the most commonly used browser automation tool, which is on its
way to becoming a W3C standard. You will also learn how to
configure a testing environment for Selenium WebDriver.

By the end of this chapter, you will be able to:

Explain what automation is and why it is important


Use the Selenium WebDriver
Configure the development environment for Selenium
Another Random Scribd Document
with Unrelated Content
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like