Leanpub Header

Skip to main content

Watir Recipes

The problem solving guide to Watir

The Watir Recipes book is a quick problem-solving guide to automated testing web applications with Watir or Watir-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
145
Pages
20,376Words
About

About

About the Book

Watir is a great framework for automated testing web applications. It is easy to get started with Watir, 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.

Watir Recipes will show you solutions to your problems from the experts who have already solved them. All recipe test scripts (100+) are ready-to-run. I created the target web pages and test sites, so that you can simply find the recipe 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

$20.00

$20.00

You pay

$20.00

Author earns

$16.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 2)

2
The author will earn $24.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. Get recipe test scripts
  4. Send me feedback

1.Introduction

  1. 1.1Watir and its variants
  2. 1.2RSpec
  3. 1.3Run recipe scripts

2.Watir and Selenium WebDriver

  1. 2.1Install Selenium Browser Drivers
  2. 2.2Cross browser testing with Watir
  3. 2.3Selenium WebDriver Locators
  4. 2.4Locating elements in Watir
  5. 2.5Access underneath Selenium API

3.Hyperlink

  1. 3.1Start browser
  2. 3.2Click a link by text
  3. 3.3Click Nth link with the same link text
  4. 3.4Verify a link present or not?
  5. 3.5Getting link data attributes
  6. 3.6Test links open a new browser window

4.Button

  1. 4.1Click a button by text
  2. 4.2Click a button by ID
  3. 4.3Click a button by name
  4. 4.4Click an image button
  5. 4.5Assert a button present
  6. 4.6Assert a button displayed or hidden?
  7. 4.7Assert 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

6.Radio button

  1. 6.1Select radio button by name and value
  2. 6.2Select radio button by ID
  3. 6.3Clear radio option selection
  4. 6.4Assert a radio option is selected
  5. 6.5Iterate radio buttons in a radio group

7.CheckBox

  1. 7.1Select by name
  2. 7.2Select by ID
  3. 7.3Uncheck a checkbox
  4. 7.4Assert a checkbox is checked (or not)

8.Select List

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

9.Navigation and Browser

  1. 9.1Go to a URL
  2. 9.2Go to pages within the site without specifying full URL
  3. 9.3Perform actions from right click context menu such as ‘Back’, ‘Forward’ or ‘Refresh’
  4. 9.4Maximize browser window
  5. 9.5Minimize browser window
  6. 9.6Set typing speed
  7. 9.7Attaching browser
  8. 9.8Reuse browser
  9. 9.9Resizing browser window
  10. 9.10Remember current web page URL, then come back to it later
  11. 9.11Scroll to the bottom of a page
  12. 9.12Scroll to focus on a control
  13. 9.13Switch browser or tab

10.Assertion

  1. 10.1Assert page title
  2. 10.2Assert page text
  3. 10.3Assert page source
  4. 10.4Assert browser status
  5. 10.5Assert label text
  6. 10.6Assert span text
  7. 10.7Assert div text or HTML
  8. 10.8Assert table text
  9. 10.9Assert text in a table cell
  10. 10.10Assert text in a table row
  11. 10.11Assert image present

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 an object to be present

13.File Upload and Popup dialogs

  1. 13.1File upload
  2. 13.2JavaScript pop ups
  3. 13.3Timeout on an operation
  4. 13.4Popup Handler approach
  5. 13.5Handle JavaScript dialog with Popup Handler
  6. 13.6Basic or Proxy Authentication dialog
  7. 13.7Internet Explorer modal dialog

14.Debugging Test Scripts

  1. 14.1Print text for debugging
  2. 14.2Write text to IDE output
  3. 14.3Write page source or element HTML into a file
  4. 14.4Take screenshot
  5. 14.5Using IRB
  6. 14.6Leave browser open after test finishes
  7. 14.7Pause/Stop test execution at a certain step
  8. 14.8Run selected test steps against current browser

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 random person names, emails, addresses with Faker
  8. 15.8Generate a test file at fixed sizes
  9. 15.9Retrieve 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.4Test downloading PDF in Firefox
  5. 16.5Start Firefox with extension
  6. 16.6Manage Cookies
  7. 16.7Headless Chrome
  8. 16.8Test responsive websites

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

18.HTML 5 and JavaScript

  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.5Chosen - Standard Select
  6. 18.6Chosen - Multiple Select
  7. 18.7AngularJS web pages
  8. 18.8Ember JS web pages
  9. 18.9“Share Location” with Firefox
  10. 18.10Faking Geolocation with JavaScript

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
  13. 20.13Quick extract pattern text in comments with Regex
  14. 20.14Invoke element’s JavaScript events such as ‘onclick’

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.7Test 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.4Element is not clickable or not visible
  6. 22.5Lack knowledge of the programming language

23.Watir with Cucumber

  1. 23.1How Watir is integrated with Cucumber?
  2. 23.2Execute Cucumber tests
  3. 23.3Cucumber or RSpec?

Afterword

Resources

  1. Books
  2. Websites
  3. 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