Leanpub Header

Skip to main content

Selenium WebDriver Recipes in Java

The problem solving guide to Selenium WebDriver in Java

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!

Pick Your Price...
PDF
EPUB
WEB
184
Pages
22,755Words
About

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 Java 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.

Share this book

Categories

Price

Pick Your Price...

Minimum price

$15.00

$25.00

You pay

$25.00

Author earns

$20.00
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 1)

1
The author will earn $12.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

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

  1. Who should read this book
  2. How to read this book
  3. Recipe test scripts
  4. Send me feedback

1.Introduction

  1. 1.1Selenium
  2. 1.2Selenium language bindings
  3. 1.3Cross browser testing
  4. 1.4JUnit
  5. 1.5Set up Development Environment
  6. 1.6Set up Intellij IDEA project
  7. 1.7Run recipe scripts

2.Locating web elements

  1. 2.1Start browser
  2. 2.2Find element by ID
  3. 2.3Find element by Name
  4. 2.4Find element by Link Text
  5. 2.5Find element by Partial Link Text
  6. 2.6Find element by XPath
  7. 2.7Find element by Tag Name
  8. 2.8Find element by Class
  9. 2.9Find element by CSS Selector
  10. 2.10Chain findElement to find child elements
  11. 2.11Find multiple elements

3.Hyperlink

  1. 3.1Click a link by text
  2. 3.2Click a link by ID
  3. 3.3Click a link by partial text
  4. 3.4Click a link by XPath
  5. 3.5Click Nth link with exact same label
  6. 3.6Click Nth link by CSS Selector
  7. 3.7Verify a link present or not?
  8. 3.8Getting link data attributes
  9. 3.9Test links open a new browser window

4.Button

  1. 4.1Click a button by label
  2. 4.2Click a form button by label
  3. 4.3Submit a form
  4. 4.4Click a button by ID
  5. 4.5Click a button by name
  6. 4.6Click a image button
  7. 4.7Click a button via JavaScript
  8. 4.8Assert a button present
  9. 4.9Assert a button enabled or disabled?

5.TextField and TextArea

  1. 5.1Enter text into a text field by name
  2. 5.2Enter text into a text field by ID
  3. 5.3Enter text into a password field
  4. 5.4Clear a text field
  5. 5.5Enter text into a multi-line text area
  6. 5.6Assert value
  7. 5.7Focus on a control
  8. 5.8Set a value to a read-only or disabled text field
  9. 5.9Set and assert the value of a hidden field

6.Radio button

  1. 6.1Select a radio button
  2. 6.2Clear radio option selection
  3. 6.3Assert a radio option is selected
  4. 6.4Iterate radio buttons in a radio group
  5. 6.5Click Nth radio button in a group
  6. 6.6Click radio button by the following label
  7. 6.7Customized Radio buttons - iCheck

7.CheckBox

  1. 7.1Check by name
  2. 7.2Check by id
  3. 7.3Uncheck a checkbox
  4. 7.4Assert a checkbox is checked (or not)
  5. 7.5Customized Checkboxes - iCheck

8.Select List

  1. 8.1Select an option by text
  2. 8.2Select an option by value
  3. 8.3Select an option by iterating all options
  4. 8.4Select multiple options
  5. 8.5Clear one selection
  6. 8.6Clear all selections
  7. 8.7Assert label or value in a select list
  8. 8.8Assert selected option label
  9. 8.9Assert the value of a select list
  10. 8.10Assert multiple selections

9.Navigation and Browser

  1. 9.1Go to a URL
  2. 9.2Visit pages within a site
  3. 9.3Perform actions from right click context menu such as ‘Back’, ‘Forward’ or ‘Refresh’
  4. 9.4Open browser in certain size
  5. 9.5Maximize browser window
  6. 9.6Move browser window
  7. 9.7Minimize browser window
  8. 9.8Scroll focus to control
  9. 9.9Switch between browser windows or tabs
  10. 9.10Open new and close browser Tabs
  11. 9.11Remember current web page URL, then come back to it later

10.Assertion

  1. 10.1Assert page title
  2. 10.2Assert Page Text
  3. 10.3Assert Page Source
  4. 10.4Assert Label Text
  5. 10.5Assert Span text
  6. 10.6Assert Div text or HTML
  7. 10.7Assert Table text
  8. 10.8Assert text in a table cell
  9. 10.9Assert text in a table row
  10. 10.10Assert image present
  11. 10.11Assert element location and width
  12. 10.12Assert element CSS style
  13. 10.13Assert JavaScript errors on a web page

11.Frames

  1. 11.1Testing Frames
  2. 11.2Testing iframe
  3. 11.3Test multiple iframes

12.Testing AJAX

  1. 12.1Wait within a time frame
  2. 12.2Explicit Waits until Time out
  3. 12.3Implicit Waits until Time out
  4. 12.4Wait AJAX Call to complete using JQuery

13.File Upload and Popup dialogs

  1. 13.1File upload
  2. 13.2JavaScript pop ups
  3. 13.3Timeout on a test
  4. 13.4Modal style dialogs
  5. 13.5Popup Handler Approach
  6. 13.6Handle JavaScript dialog with Popup Handler
  7. 13.7Basic or Proxy Authentication Dialog
  8. 13.8Internet Explorer modal dialog

14.Debugging Test Scripts

  1. 14.1Print text for debugging
  2. 14.2Write page source or element HTML into a file
  3. 14.3Take screenshot
  4. 14.4Leave browser open after test finishes
  5. 14.5Debug test execution using Debugger

15.Test Data

  1. 15.1Get date dynamically
  2. 15.2Get a random boolean value
  3. 15.3Generate a number within a range
  4. 15.4Get a random character
  5. 15.5Get a random string at fixed length
  6. 15.6Get a random string in a collection
  7. 15.7Generate a test file at fixed sizes
  8. 15.8Retrieve data from Database

16.Browser Profile and Capabilities

  1. 16.1Get browser type and version
  2. 16.2Set HTTP Proxy for Browser
  3. 16.3Verify file download in Chrome
  4. 16.4Verify file download in Firefox
  5. 16.5Bypass basic authentication by embedding username and password in URL
  6. 16.6Bypass basic authentication with Firefox AutoAuth plugin
  7. 16.7Manage Cookies
  8. 16.8Headless Chrome
  9. 16.9Test responsive websites
  10. 16.10Set page load timeout

17.Advanced User Interactions

  1. 17.1Double click a control
  2. 17.2Move mouse to a control - Mouse Over
  3. 17.3Click and hold - select multiple items
  4. 17.4Context Click - right click a control
  5. 17.5Drag and drop
  6. 17.6Drag slider
  7. 17.7Send key sequences - Select All and Delete
  8. 17.8Click a specific part of an image

18.HTML 5 and Dynamic Web Sites

  1. 18.1HTML5 Email type field
  2. 18.2HTML5 Time Field
  3. 18.3Invoke ‘onclick’ JavaScript event
  4. 18.4Invoke JavaScript events such as ‘onchange’
  5. 18.5Scroll to the bottom of a page
  6. 18.6Select2 - Single Select
  7. 18.7Select2 - Multiple Select
  8. 18.8AngularJS web pages
  9. 18.9Ember JS web pages
  10. 18.10“Share Location” with Firefox
  11. 18.11Faking Geolocation with JavaScript
  12. 18.12Save a canvas to PNG image
  13. 18.13Verify dynamic charts

19.WYSIWYG HTML editors

  1. 19.1TinyMCE
  2. 19.2CKEditor
  3. 19.3SummerNote
  4. 19.4CodeMirror

20.Leverage Programming

  1. 20.1Raise exceptions to fail test
  2. 20.2Ignorable test statement error
  3. 20.3Read external file
  4. 20.4Data-Driven Tests with Excel
  5. 20.5Data-Driven Tests with CSV
  6. 20.6Identify element IDs with dynamically generated long prefixes
  7. 20.7Sending special keys such as Enter to an element or browser
  8. 20.8Use of Unicode in test scripts
  9. 20.9Extract a group of dynamic data : verify search results in order
  10. 20.10Verify uniqueness of a set of data
  11. 20.11Extract dynamic visible data rows from a results table
  12. 20.12Extract dynamic text following a pattern using Regex

21.Optimization

  1. 21.1Assert text in page_source is faster than the text
  2. 21.2Getting text from more specific element is faster
  3. 21.3Avoid programming if-else block code if possible
  4. 21.4Use variable to cache not-changed data
  5. 21.5Enter large text into a text box
  6. 21.6Use Environment Variables to change test behaviours dynamically
  7. 21.7Testing web site in two languages
  8. 21.8Multi-language testing with lookups

22.Gotchas

  1. 22.1Test starts browser but no execution with blank screen
  2. Be aware of browser and driver changes
  3. 22.2Failed to assert copied text in browser
  4. 22.3The same test works for Chrome, but not IE
  5. 22.4“unexpected tag name ‘input’”
  6. 22.5Element is not clickable or not visible

23.Selenium Remote Control Server

  1. 23.1Selenium Server Installation
  2. 23.2Execute tests in specified browser on another machine
  3. 23.3Selenium Grid

Afterword

Resources

  1. Books
  2. Web Sites
  3. Blog
  4. 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.

Learn more about writing on Leanpub