Instant Download Selenium WebDriver Recipes in Python The problem solving guide to Selenium WebDriver in Python 1st Edition Zhimin Zhan PDF All Chapters
Instant Download Selenium WebDriver Recipes in Python The problem solving guide to Selenium WebDriver in Python 1st Edition Zhimin Zhan PDF All Chapters
com
https://ebookname.com/product/selenium-webdriver-recipes-in-
python-the-problem-solving-guide-to-selenium-webdriver-in-
python-1st-edition-zhimin-zhan/
OR CLICK HERE
DOWLOAD NOW
https://ebookname.com/product/problem-solving-with-algorithms-and-
data-structures-using-python-second-edition-bradley-n-miller/
ebookname.com
https://ebookname.com/product/programming-in-python-3-a-complete-
introduction-to-the-python-language-2nd-edition-summerfield/
ebookname.com
https://ebookname.com/product/swift-s-irish-writings-selected-prose-
and-poetry-1st-ed-edition-jonathan-swift/
ebookname.com
The Didactics of Audiovisual Translation Benjamins
Translation Library Jorge Diaz Cintas
https://ebookname.com/product/the-didactics-of-audiovisual-
translation-benjamins-translation-library-jorge-diaz-cintas/
ebookname.com
https://ebookname.com/product/pathfinder-roleplaying-game-
bestiary-2-1st-edition-paizo-staff/
ebookname.com
https://ebookname.com/product/hippolytus-the-bacchae-webster-s-
spanish-thesaurus-edition-euripides/
ebookname.com
https://ebookname.com/product/oxford-international-primary-science-
stage-5-age-9-10-student-workbook-5-alan-haigh/
ebookname.com
https://ebookname.com/product/postpartum-mood-and-anxiety-disorders-a-
guide-1st-edition-cheryl-tatano-beck/
ebookname.com
Building Business Government Relations A Skills Approach
1st Edition Anna Ya Ni
https://ebookname.com/product/building-business-government-relations-
a-skills-approach-1st-edition-anna-ya-ni/
ebookname.com
Selenium WebDriver Recipes in Python
The problem solving guide to Selenium WebDriver in
Python
Zhimin Zhan
This book is for sale at http://leanpub.com/selenium-recipes-in-python
This is a Leanpub book. Leanpub empowers authors and publishers with the Lean
Publishing process. Lean Publishing is the act of publishing an in-progress ebook using
lightweight tools and many iterations to get reader feedback, pivot until you have the right
book and build traction once you do.
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Who should read this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
How to read this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Recipe test scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Send me feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Selenium language bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Install Selenium Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Cross browser testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 unittest - Python Unit Testing Framework . . . . . . . . . . . . . . . . . . . 8
1.5 Run recipe scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3. Hyperlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.1 Start browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 Click a link by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
CONTENTS
4. Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1 Click a button by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Click a form button by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3 Submit a form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4 Click a button by ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.5 Click a button by name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.6 Click a image button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.7 Click a button via JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.8 Assert a button present . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.9 Assert a button enabled or disabled? . . . . . . . . . . . . . . . . . . . . . . . 28
6. Radio button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.1 Select a radio button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.2 Clear radio option selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.3 Assert a radio option is selected . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.4 Iterate radio buttons in a radio group . . . . . . . . . . . . . . . . . . . . . . 34
6.5 Click Nth radio button in a group . . . . . . . . . . . . . . . . . . . . . . . . 34
6.6 Click radio button by the following label . . . . . . . . . . . . . . . . . . . . 35
6.7 Customized Radio buttons - iCheck . . . . . . . . . . . . . . . . . . . . . . . 36
CONTENTS
7. CheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.1 Select by name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.2 Uncheck a checkbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.3 Assert a checkbox is checked (or not) . . . . . . . . . . . . . . . . . . . . . . 37
7.4 Customized Checkboxes - iCheck . . . . . . . . . . . . . . . . . . . . . . . . 38
8. Select List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.1 Select an option by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.2 Select an option by value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.3 Select an option by index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.4 Select an option by iterating all options . . . . . . . . . . . . . . . . . . . . . 40
8.5 Select multiple options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.6 Clear one selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.7 Clear all selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.8 Assert label or value in a select list . . . . . . . . . . . . . . . . . . . . . . . . 41
8.9 Assert selected option label . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.10 Assert the value of a select list . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.11 Assert multiple selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
10. Assertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
10.1 Assert page title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
10.2 Assert Page Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
10.3 Assert Page Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
10.4 Assert Label Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
10.5 Assert Span text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
CONTENTS
11. Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
11.1 Testing Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
11.2 Testing IFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
11.3 Test multiple iframes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Afterword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Web Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Preface
After observing many failed test automation attempts by using expensive commercial test
automation tools, I am delighted to see that the value of open-source testing frameworks has
finally been recognized. I still remember the day (a rainy day at a Gold Coast hotel in 2011)
when I found out that the Selenium WebDriver was the most wanted testing skill in terms
of the number of job ads on the Australia’s top job-seeking site.
Now Selenium WebDriver is big in the testing world. We all know software giants such
as Facebook and LinkedIn use it, immensely-comprehensive automated UI testing enables
them pushing out releases several times a day¹. However, from my observation, many
software projects, while using Selenium, are not getting much value from test automation,
and certainly nowhere near its potential. A clear sign of this is that the regression testing is
not conducted on a daily basis (if test automation is done well, it will happen naturally).
Among the factors contributing to test automation failures, a key one is that automation
testers lack sufficient knowledge in the test framework. It is quite common to see some
testers or developers get excited when they first create a few simple test cases and see them
run in a browser. However, it doesn’t take long for them to encounter some obstacles: such as
being unable to automate certain operations. If one step cannot be automated, the whole test
case does not work, which is the nature of test automation. Searching solutions online is not
always successful, and posting questions on forums and waiting can be frustrating (usually,
very few people seek professional help from test automation coaches). Not surprisingly,
many projects eventually gave up test automation or just used it for testing a handful of
scenarios.
The motivation of this book is to help motivated testers work better with Selenium. The book
contains over 190 recipes for web application tests with Selenium. If you have read one of
my other books: Practical Web Test Automation², you probably know my style: practical. I
will let the test scripts do most of the talking. These recipe test scripts are ‘live’, as I have
created the target test site and included offline test web pages. With both, you can:
Usually, a ‘recipe’ book is a reference book. Readers can go directly to the part that interests
them. For example, if you are testing a multiple select list and don’t know how, you can look
up in the Table of Contents, then go to the chapter 8. This book supports this style of reading.
If you are new to Selenium WebDriver, I recommend you to try out the recipes from the
front to back. The recipes in the first half of the book are arranged according to their levels of
complexity, I believe readers can get the pattern of testing with Selenium and gain confidence
after going through them.
Send me feedback
I would appreciate your comments, suggestions, reports on errors in the book and the recipe
test scripts. You may submit your feedback on the book’s site.
Zhimin Zhan
Brisbane, Australia
1. Introduction
Selenium is a free and open source library for automated testing web applications. Selenium
was originally created in 2004 by Jason Huggins, it merged with another test framework
WebDriver in 2011 (that’s why is named ‘selenium-webdriver’) led by Simon Stewart at
Google (update: Simon now works at FaceBook). As WebDriver is a W3C standard¹, it gains
support from all major browser vendors, as a result, Selenium WebDriver quickly become
the de facto framework for automated testing web applications.
¹https://www.w3.org/TR/webdriver/
Introduction 2
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
C#:
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
class GoogleSearch
{
static void Main()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Hello Selenium WebDriver!");
Other documents randomly have
different content
[25] Zum letzteren vergleiche auch Max B ü c h l e r , Joh. Heinr. v.
Thünen und seine nationalökonomischen Hauptlehren, Bern
1907, S. 16 ff.
Literaturnachweise.
(Die für das Studium unentbehrlichen Hauptwerke sind durch ein Sternchen hinter
dem Verfassernamen kenntlich gemacht.)
I. Gesamtdarstellungen.
c) Z u r logischen Elementarlehre:
B. E r d m a n n , Logische Studien, in: Viert. s. wiss. Philos., Bd. VI, 1882, Bd. VII,
1883.
— Zur Theorie des Syllogismus und der Induktion, in: Philos. Aufs., Ed. Zeller
gew., Leipzig 1887.
Chr. S i g w a r t , Beiträge zur Lehre vom hypothetischen Urteile, Tübingen 1871.
— Die Impersonalien, eine logische Untersuchung, Freiburg 1888.
Alois R i e h l , Beiträge zur Logik, 2. Aufl., Leipzig 1912.
Wilhelm W i n d e l b a n d , Beiträge zur Lehre vom negativen Urteil, in: Straßburger
Abhandl. zur Philos., Ed. Zeller gew., Leipzig 1884.
— Vom System der Kategorien, in: Philos. Abhandlungen, Chr. Sigwart gew.,
Tübingen 1900.
Hans C o r n e l i u s , Versuch einer Theorie der Existentialurteile, München 1894.
Adolf D y r o f f , Über den Existentialbegriff, Freiburg 1902.
Fritz M e d i c u s , Bemerkungen zum Problem der Existenz mathematischer
Gegenstände, in: Festschrift der Kantstudien zum 70. Geb. Al. Riehls, Berlin
1914.
Joh. Ed. Th. W i l d s c h r e y , Die Grundlagen einer vollständigen Syllogistik, Halle
1907.
Ferner: Friedrich Albert L a n g e , Logische Studien, Iserlohn 1877.
A. M a r t y , Über subjektlose Sätze, in: Viert. f. wiss. Philos. Bd. 8, 1884; Bd. 18,
1894.
d) Z u r logischen Methodenlehre:
John Stuart M i l l *, System der deduktiven und induktiven Logik, 3 Bde., deutsch
in: Ges. Werke, herausg. v. Theod. Gompertz, Bd. 2-4, Leipzig 1872-1873.
Richard H ö n i g s w a l d , Beiträge zur Erkenntnistheorie und Methodenlehre,
Leipzig 1906.
Bruno B a u c h , Studien zur Philosophie der exakten Wissenschaften, Heidelberg
1911.
Johannes von K r i e s , Logik, Tübingen 1916.
Ferner: B. E r d m a n n , Theorie der Typen-Einteilungen, in: Philos. Monatshefte,
Bd. 30, Berlin 1884.
— Methodologische Konsequenzen aus der Theorie der Abstraktion (Abh. d. Kgl.
Pr. Akad. d. Wiss.), Berlin 1916.
Heinrich R i c k e r t , Zur Lehre von der Definition, 2. Aufl., Tübingen 1915.
Zur Einführung in die zahlreichen methodologischen Probleme des
m a t h e m a t i s c h e n D e n k e n s vergleiche man: B. E r d m a n n , Die Axiome
der Geometrie, Leipzig 1877; O. H ö l d e r , Anschauung und Denken in der
Geometrie, Leipzig 1900; Jonas C o h n , Voraussetzungen und Ziele des
Erkennens, Leipzig 1908, Teil II; Richard H ö n i g s w a l d , Zum Streit über die
Grundlagen der Mathematik, Heidelberg 1912; A. Vo ß , Über das Wesen der
Mathematik, Leipzig 1913; sowie die dort angeführte Literatur.
Zur neueren Logik der G e s c h i c h t s w i s s e n s c h a f t : Wilh. W i n d e l b a n d ,
Naturwissenschaft und Geschichte, 2. Aufl., Straßburg 1900 (auch in: Präludien
Bd. II, Tübingen 1915); Ed. M e y e r , Zur Theorie und Methodik der Geschichte,
Halle 1902; Heinrich R i c k e r t , Die Grenzen der naturwissenschaftlichen
Begriffsbildung, Tübingen 1902; Über die Aufgaben einer Logik der Geschichte,
Archiv f. syst. Phil., Bd. 8, 1902; Kulturwissenschaft und Naturwissenschaft, 2.
Aufl., Tübingen 1910; Geschichtsphilosophie, in: Die Philosophie im Beginn des
20. Jahrh., Festschr. f. Kuno Fischer, 2. Aufl., Heidelberg 1907; ferner: Eduard
S p r a n g e r , Die Grundlagen der Geschichtswissenschaft, Berlin 1905; Kurt
S t e r n b e r g , Zur Logik der Geschichtswissenschaft, Philos. Vortr. Nr. 7, Berlin
1914; Heinrich M a i e r , Das geschichtliche Erkennen, Göttingen 1914; sowie
einzelne Schriften von Ernst B e r n h e i m .
Zur Frage nach der systematischen G l i e d e r u n g der Wissenschaften: Wilh.
W u n d t , Über die Einteilung der Wissenschaften, in Philos. Studien, Bd. 5,
Leipzig 1888; B. E r d m a n n , Die Gliederung der Wissenschaften, in: Viert. f.
wiss. Philos., Bd. 2, Leipzig 1878; Alfred H e t t n e r , Das System der
Wissenschaften, in: Preuß. Jahrbücher, Bd. 122, Berlin 1905; Carl S t u m p f , Zur
Einteilung der Wissenschaften, Berlin 1906; Richard H ö n i g s w a l d , Vom
allgemeinen System der Wissenschaften, in: Philos. Wochenschr., Bd. 4, Leipzig
1906; Zur Wissenschaftstheorie und -systematik, in Kant-Studien, Bd. 17, Berlin
1912.
Sachregister.
Abstrakte Allgemeinvorstellung 18 f.
Abstraktheit von Begriffen 21.
Abstraktion 27, 28.
Allgemeines (universales) Urteil 33, 46 f., 58 f.
Analogieschluß 78, 98 ff., 129, 131.
Analyse 109 ff.
Analytisches Urteil 33 Anm.
Apodiktisches Urteil 33, 35, 60 f., 73.
Approximatives Urteil 62.
Artbegriff, artbildender Unterschied 29 f.
Assertorisches Urteil 33, 35, 60 f.
Ausgeschlossenes Dritte (Grundsatz) 9, 14, 43 f., 77.
Axiom 44, 93, 124.
Idealurteil 33 f.
Identität (Grundsatz) 14, 24.
Immanenz, logische 40, 46.
Impersonalien: s. Subjekt-unbestimmte Urteile.
Individualbegriff 21, 29 f., 46.
Induktive Logik 15, 98.
Induktiver Schluß 9, 11, 12, 78, 93 ff., 114 f., 128 f., 131.
Inhalt von Begriffen 23 ff.
Inhaltslogik 37.
Inhaltstheorien des Urteils (des Schlußverfahrens) 37 ff., 92.
Inhärenzsyllogismus 84.
Inhärenzurteil 34, 49 ff., 92, 110.
Intuition und intuitives Denken 11, 17, 20.
Kategorie 9, 14, 31 f.
Kategorisches Urteil (bzw. Schluß) 33, 78 f., 89, 91.
Kausalgesetz, Kausalität 12, 31, 53, 97, 100, 116, 124.
Kausalurteil 34, 49, 53 f.
Kette 79, 89 f., 113.
Klassifikation 107, 120 ff.
Klassifikatorisches Urteil 34, 50 f.
Kollektivbegriff 21, 29.
Konjunktives Urteil 35, 63, 94 f., 96, 108.
Konstituierendes Merkmal 24 ff., 42 f.
Kontradictio in adjecto 28.
Kontradiktorisch-entgegengesetzte Begriffe (Urteile) 28, 43 f., 76 f.
Kontraposition 75.
Konträr-entgegengesetzte Begriffe (Urteile) 28, 76 f.
Konversion 73 f., 84, 86.
Kopulatives Urteil 35, 63, 94 f., 96.
Materiale Frage 70 f.
Materiale Gültigkeit 42 ff., 73.
Materie des Denkens 4 f., 42.
Mathematische Logik 15, 38.
Merkmal 23 f., 33, 39.
Metaphysische Logik 9, 14, 15.
Mittelbare Bejahung 58, 73.
Mittelbares Urteil 92.
Mittelbare Verneinung 57 f., 73.
Mittelbegriff 80, 84 f., 131.
Modal-bestimmte Urteile 35, 56, 60 ff.
Modalität 31, 35, 56, 60 ff.
Opposition 76.
Ordnungsreihe des Denkens 30 f., 50.
Paralogismus 80.
Partikuläres Urteil: s. besonderes Urteil.
Prädikat 4, 34, 36 f., 38 f., 42 f., 46, 49 ff.
Prädikation (log. Grundsatz) 42 f.
Prädikativer Inhalt 25.
Problematisches Urteil 33, 35, 61 f., 65.
Problemfrage 72, 123 f.
Psychologie des Denkens 7, 16 f.
Psychologisierende Logik 12, 15, 36.
Realitätsproblem 55.
Realurteil 33 f., 67, 105.
Realwissenschaft 104.
Relation 31 f., 33, 46, 92.
Relationsmerkmal 25.
Relationssyllogismus 84, 92, 100 f.
Relationsurteil 4, 34, 49, 52 ff., 84 f., 90, 110.
Relativer Inhalt 25.
Reziprokables Urteil 74.
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.
ebookname.com