Selenium WebDriver Recipes in Python
The problem solving guide to Selenium WebDriver in Python
The Selenium WebDriver Recipes book is a quick problem-solving guide to automated testing web applications with Selenium WebDriver. It contains hundreds of solutions to real-world problems, with clear explanations and ready-to-run test scripts you can use in your own projects.
The author is letting you choose the price you pay for this book!
The Selenium WebDriver Recipes book is a quick problem-solving guide to automated testing web applications with Selenium WebDriver. It contains hundreds of solutions to real-world problems, with clear explanations and ready-to-run test scripts you can use in your own projects.
About
About the Book
Selenium WebDriver is a popular browser automation framework. Testers or developers with Selenium skills are in high demand. It is easy to get started with Selenium, but do you use effectively for testing real-world test scenarios? Such as data driving test from an Excel spreadsheet and handling pop up dialogs.
Selenium WebDriver Recipes will show you solutions to your problems from the experts who have already solved them. All recipe tests (~200 in Python language) are ready-to-run. I created the target web site and offline web pages, so that you can simply find the recipes and run, in a matter of seconds. Owning this book is like having a test automation coach sitting next to you.
Price
Pick Your Price...
Minimum price
$15.00
$25.00
You pay
$25.00Author earns
$20.00Author
About the Author
Zhimin Zhan
Zhimin Zhan is the founder and principal agile testing coach of AgileWay Pty Ltd, Australia. As an advisor and coach, he helps organisations implement test automation using Continuous Testing with open technologies, such as Selenium WebDriver / Appium. Zhimin is the creator of TestWise, the next-generation functional testing tool that supports functional test refactorings, and BuildWise, an international award-winning Continuous Testing Server. Zhimin is a frequent speaker and author of 14 books on software testing and programming. He shares his test automation and CI experience on Substack and Medium.
Contents
Table of Contents
Preface
- Who should read this book
- How to read this book
- Recipe test scripts
- Send me feedback
1.Introduction
- 1.1Selenium language bindings
- 1.2Install Selenium Python
- 1.3Cross browser testing
- 1.4unittest - Python Unit Testing Framework
- 1.5Run recipe scripts
2.Locating web elements
- 2.1Start browser
- 2.2Find element by ID
- 2.3Find element by Name
- 2.4Find element by Link Text
- 2.5Find element by Partial Link Text
- 2.6Find element by XPath
- 2.7Find element by Tag Name
- 2.8Find element by Class Name
- 2.9Find element by CSS Selector
- 2.10Chain find_element to find child elements
- 2.11Find multiple elements
3.Hyperlink
- 3.1Start browser
- 3.2Click a link by text
- 3.3Click a link by ID
- 3.4Click a link by partial text
- 3.5Click a link by XPath
- 3.6Click Nth link with exact same label
- 3.7Click Nth link by CSS
- 3.8Verify a link present or not?
- 3.9Getting link data attributes
- 3.10Test links open a new browser window
4.Button
- 4.1Click a button by text
- 4.2Click a form button by text
- 4.3Submit a form
- 4.4Click a button by ID
- 4.5Click a button by name
- 4.6Click a image button
- 4.7Click a button via JavaScript
- 4.8Assert a button present
- 4.9Assert a button enabled or disabled?
5.TextField and TextArea
- 5.1Enter text into a text field by name
- 5.2Enter text into a text field by ID
- 5.3Enter text into a password field
- 5.4Clear a text field
- 5.5Enter text into a multi-line text area
- 5.6Assert value
- 5.7Focus on a control
- 5.8Set a value to a read-only or disabled text field
- 5.9Set and assert the value of a hidden field
6.Radio button
- 6.1Select a radio button
- 6.2Clear radio option selection
- 6.3Assert a radio option is selected
- 6.4Iterate radio buttons in a radio group
- 6.5Click Nth radio button in a group
- 6.6Click radio button by the following label
- 6.7Customized Radio buttons - iCheck
7.CheckBox
- 7.1Select by name
- 7.2Uncheck a checkbox
- 7.3Assert a checkbox is checked (or not)
- 7.4Customized Checkboxes - iCheck
8.Select List
- 8.1Select an option by text
- 8.2Select an option by value
- 8.3Select an option by index
- 8.4Select an option by iterating all options
- 8.5Select multiple options
- 8.6Clear one selection
- 8.7Clear all selections
- 8.8Assert label or value in a select list
- 8.9Assert selected option label
- 8.10Assert the value of a select list
- 8.11Assert multiple selections
9.Navigation and Browser
- 9.1Go to a URL
- 9.2Visit pages within a site
- 9.3Perform actions from right mouse click context menu such as ‘Back’, ‘Forward’ or ‘Refresh’
- 9.4Open browser in certain size
- 9.5Maximize browser window
- 9.6Move browser window
- 9.7Minimize browser window
- 9.8Scroll focus to control
- 9.9Switch between browser windows or tabs
- 9.10Open new and close browser Tabs
- 9.11Remember current web page URL, then come back to it later
10.Assertion
- 10.1Assert page title
- 10.2Assert Page Text
- 10.3Assert Page Source
- 10.4Assert Label Text
- 10.5Assert Span text
- 10.6Assert Div text or HTML
- 10.7Assert Table text
- 10.8Assert text in a table cell
- 10.9Assert text in a table row
- 10.10Assert image present
- 10.11Assert element location and width
- 10.12Assert element CSS style
- 10.13Assert JavaScript errors on a web page
11.Frames
- 11.1Testing Frames
- 11.2Testing IFrame
- 11.3Test multiple iframes
12.Testing AJAX
- 12.1Wait within a time frame
- 12.2Explicit Waits until Time out
- 12.3Implicit Waits until Time out
- 12.4Create your own polling check function
- 12.5Wait AJAX Call to complete using JQuery
13.File Upload and Popup dialogs
- 13.1File upload
- 13.2JavaScript pop ups
- 13.3Modal style dialogs
- 13.4Bypass basic authentication by embedding username and password in URL
- 13.5Internet Explorer modal dialog
- 13.6Popup Handler Approach
- 13.7Handle JavaScript dialog with Popup Handler
- 13.8Basic or Proxy Authentication Dialog
14.Debugging Test Scripts
- 14.1Print text for debugging
- 14.2Write page source or element HTML into a file
- 14.3Take screenshot
- 14.4Leave browser open after test finishes
- 14.5Debug test execution using Debugger
- 14.6Attach test executions to an existing browser
15.Test Data
- 15.1Get date dynamically
- 15.2Get a random boolean value
- 15.3Generate a number within a range
- 15.4Get a random character
- 15.5Get a random string at fixed length
- 15.6Get a random string in a collection
- 15.7Generate random person names, emails, addresses with Faker
- 15.8Generate a test file at fixed sizes
- 15.9Retrieve data from Database
16.Browser Profile and Capabilities
- 16.1Get browser type and version
- 16.2Set HTTP Proxy for Browser
- 16.3Verify file download in Chrome
- 16.4Test downloading PDF in Firefox
- 16.5Bypass basic authentication with Firefox AutoAuth plugin
- 16.6Manage Cookies
- 16.7Headless browser testing with PhantomJS
- 16.8Headless Chrome
- 16.9Headless Firefox
- 16.10Test responsive websites
- 16.11Set page load timeout
- 16.12Device emulation on Chrome
17.Advanced User Interactions
- 17.1Double click a control
- 17.2Move mouse to a control - Mouse Over
- 17.3Click and hold - select multiple items
- 17.4Context Click - right click a control
- 17.5Drag and drop
- 17.6Drag slider
- 17.7Send key sequences - Select All and Delete
- 17.8Click a specific part of an image
18.HTML 5 and Dynamic Web Sites
- 18.1HTML5 Email type field
- 18.2HTML5 Time Field
- 18.3Invoke ‘onclick’ JavaScript event
- 18.4Invoke JavaScript events such as ‘onchange’
- 18.5Scroll to the bottom of a page
- 18.6Select2 - Single Select
- 18.7Select2 - Multiple Select
- 18.8AngularJS web pages
- 18.9Ember JS web pages
- 18.10“Share Location” with Firefox
- 18.11Faking Geolocation with JavaScript
- 18.12Save a canvas to PNG image
- 18.13Verify dynamic charts
19.WYSIWYG HTML editors
- 19.1TinyMCE
- 19.2CKEditor
- 19.3SummerNote
- 19.4CodeMirror
20.Leverage Programming
- 20.1Raise exceptions to fail test
- 20.2Ignorable test statement error
- 20.3Read external file
- 20.4Data-Driven Tests with Excel
- 20.5Data-Driven Tests with CSV
- 20.6Identify element IDs with dynamically generated long prefixes
- 20.7Sending special keys such as Enter to an element or browser
- 20.8Use of unicode in test scripts
- 20.9Extract a group of dynamic data : verify search results in order
- 20.10Verify uniqueness of a set of data
- 20.11Extract dynamic visible data rows from a results table
- 20.12Extract dynamic text following a pattern using Regex
- 20.13Quick extract pattern text in comments with Regex
21.Optimization
- 21.1Assert page_source is faster than page text
- 21.2Getting text from specific element is faster
- 21.3Avoid programming if-else block if possible
- 21.4Use variable to cache not-changed data
- 21.5Enter large text into a text box
- 21.6Use Environment Variables to change test behaviours dynamically
- 21.7Test web site in two languages
- 21.8Multi-language testing with lookups
22.Gotchas
- 22.1Test starts browser but no execution with blank screen
- Be aware of browser and driver changes
- 22.2Failed to assert copied text in browser
- 22.3The same test works for Chrome, but not IE
- 22.4“unexpected tag name ‘input’”
- 22.5Element is not clickable or not visible
23.Material Design Web App
- 23.1Select List (dropdown)
- 23.2Checkbox
- 23.3Drag range (noUiSlider)
- 23.4Verify Toast message
- 23.5Modal
24.Selenium Remote Control Server
- 24.1Selenium Server Installation
- 24.2Execute tests in specified browser on another machine
- 24.3Selenium Grid
Appendix - Continuous Testing
- Verify server machine can run Selenium Python
- Install BuildWise Server
- Create Build Project in BuildWise
- Trigger test execution manually
- Feedback while test execution in progress
- Build finished
- Notification
- Review
Afterword
Resources
- Books
- Web Sites
- Blog
- Tools
Get the free sample chapters
Click the buttons to get the free sample in PDF or EPUB, or read the sample online here
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.