Watir Recipes
Watir Recipes
The problem solving guide to Watir
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.
Bundles that include this book
Reader Testimonials
Paul Farrell
Software Tester
'Watir Recipes' gets a lot of use in my job, Thank you.
Table of Contents
-
- Preface
- Who should read this book
- How to read this book
- Get recipe test scripts
- Send me feedback
-
1. Introduction
- 1.1 Watir and its variants
- 1.2 RSpec
- 1.3 Run recipe scripts
-
2. Watir and Selenium WebDriver
- 2.1 Install Selenium Browser Drivers
- 2.2 Cross browser testing with Watir
- 2.3 Selenium WebDriver Locators
- 2.4 Locating elements in Watir
- 2.5 Access underneath Selenium API
-
3. Hyperlink
- 3.1 Start browser
- 3.2 Click a link by text
- 3.3 Click Nth link with the same link text
- 3.4 Verify a link present or not?
- 3.5 Getting link data attributes
- 3.6 Test links open a new browser window
-
4. Button
- 4.1 Click a button by text
- 4.2 Click a button by ID
- 4.3 Click a button by name
- 4.4 Click an image button
- 4.5 Assert a button present
- 4.6 Assert a button displayed or hidden?
- 4.7 Assert a button enabled or disabled?
-
5. TextField and TextArea
- 5.1 Enter text into a text field by name
- 5.2 Enter text into a text field by ID
- 5.3 Enter text into a password field
- 5.4 Clear a text field
- 5.5 Enter text into a multi-line text area
- 5.6 Assert value
- 5.7 Focus on a control
- 5.8 Set a value to a read-only or disabled text field
-
6. Radio button
- 6.1 Select radio button by name and value
- 6.2 Select radio button by ID
- 6.3 Clear radio option selection
- 6.4 Assert a radio option is selected
- 6.5 Iterate radio buttons in a radio group
-
7. CheckBox
- 7.1 Select by name
- 7.2 Select by ID
- 7.3 Uncheck a checkbox
- 7.4 Assert a checkbox is checked (or not)
-
8. Select List
- 8.1 Select an option by text or value
- 8.2 Select an option by ID
- 8.3 Select an option by iterating all options
- 8.4 Select multiple options
- 8.5 Clear selection
- 8.6 Assert selected option
- 8.7 Assert the value of a select list
- 8.8 Assert option text in a select list
- 8.9 Assert multiple selections
-
9. Navigation and Browser
- 9.1 Go to a URL
- 9.2 Go to pages within the site without specifying full URL
- 9.3 Perform actions from right click context menu such as ‘Back’, ‘Forward’ or ‘Refresh’
- 9.4 Maximize browser window
- 9.5 Minimize browser window
- 9.6 Set typing speed
- 9.7 Attaching browser
- 9.8 Reuse browser
- 9.9 Resizing browser window
- 9.10 Remember current web page URL, then come back to it later
- 9.11 Scroll to the bottom of a page
- 9.12 Scroll to focus on a control
- 9.13 Switch browser or tab
-
10. Assertion
- 10.1 Assert page title
- 10.2 Assert page text
- 10.3 Assert page source
- 10.4 Assert browser status
- 10.5 Assert label text
- 10.6 Assert span text
- 10.7 Assert div text or HTML
- 10.8 Assert table text
- 10.9 Assert text in a table cell
- 10.10 Assert text in a table row
- 10.11 Assert image present
-
11. Frames
- 11.1 Testing Frames
- 11.2 Testing iframe
- 11.3 Test multiple iframes
-
12. Testing AJAX
- 12.1 Wait within a time frame
- 12.2 Explicit Waits until Time out
- 12.3 Implicit Waits until Time out
- 12.4 Wait an object to be present
-
13. File Upload and Popup dialogs
- 13.1 File upload
- 13.2 JavaScript pop ups
- 13.3 Timeout on an operation
- 13.4 Popup Handler approach
- 13.5 Handle JavaScript dialog with Popup Handler
- 13.6 Basic or Proxy Authentication dialog
- 13.7 Internet Explorer modal dialog
-
14. Debugging Test Scripts
- 14.1 Print text for debugging
- 14.2 Write text to IDE output
- 14.3 Write page source or element HTML into a file
- 14.4 Take screenshot
- 14.5 Using IRB
- 14.6 Leave browser open after test finishes
- 14.7 Pause/Stop test execution at a certain step
- 14.8 Run selected test steps against current browser
-
15. Test Data
- 15.1 Get date dynamically
- 15.2 Get a random boolean value
- 15.3 Generate a number within a range
- 15.4 Get a random character
- 15.5 Get a random string at fixed length
- 15.6 Get a random string in a collection
- 15.7 Generate random person names, emails, addresses with Faker
- 15.8 Generate a test file at fixed sizes
- 15.9 Retrieve data from Database
-
16. Browser Profile and Capabilities
- 16.1 Get browser type and version
- 16.2 Set HTTP Proxy for Browser
- 16.3 Verify file download in Chrome
- 16.4 Test downloading PDF in Firefox
- 16.5 Start Firefox with extension
- 16.6 Manage Cookies
- 16.7 Headless Chrome
- 16.8 Test responsive websites
-
17. Advanced User Interactions
- 17.1 Double click a control
- 17.2 Move mouse to a control - Mouse Over
- 17.3 Click and hold - select multiple items
- 17.4 Context Click - right click a control
- 17.5 Drag and drop
- 17.6 Drag slider
- 17.7 Send key sequences - Select All and Delete
-
18. HTML 5 and JavaScript
- 18.1 HTML5 Email type field
- 18.2 HTML5 Time Field
- 18.3 Invoke ‘onclick’ JavaScript event
- 18.4 Invoke JavaScript events such as ‘onchange’
- 18.5 Chosen - Standard Select
- 18.6 Chosen - Multiple Select
- 18.7 AngularJS web pages
- 18.8 Ember JS web pages
- 18.9 “Share Location” with Firefox
- 18.10 Faking Geolocation with JavaScript
-
19. WYSIWYG HTML editors
- 19.1 TinyMCE
- 19.2 CKEditor
- 19.3 SummerNote
- 19.4 CodeMirror
-
20. Leverage Programming
- 20.1 Raise exceptions to fail test
- 20.2 Ignorable test statement error
- 20.3 Read external file
- 20.4 Data-Driven Tests with Excel
- 20.5 Data-Driven Tests with CSV
- 20.6 Identify element IDs with dynamically generated long prefixes
- 20.7 Sending special keys such as Enter to an element or browser
- 20.8 Use of Unicode in test scripts
- 20.9 Extract a group of dynamic data : verify search results in order
- 20.10 Verify uniqueness of a set of data
- 20.11 Extract dynamic visible data rows from a results table
- 20.12 Extract dynamic text following a pattern using Regex
- 20.13 Quick extract pattern text in comments with Regex
- 20.14 Invoke element’s JavaScript events such as ‘onclick’
-
21. Optimization
- 21.1 Assert text in page_source is faster than the text
- 21.2 Getting text from more specific element is faster
- 21.3 Avoid programming if-else block code if possible
- 21.4 Use variable to cache not-changed data
- 21.5 Enter large text into a text box
- 21.6 Use Environment Variables to change test behaviours dynamically
- 21.7 Test web site in two languages
- 21.8 Multi-language testing with lookups
-
22. Gotchas
- 22.1 Test starts browser but no execution with blank screen
- 22.2 Failed to assert copied text in browser
- 22.3 The same test works for Chrome, but not IE
- 22.4 Element is not clickable or not visible
- 22.5 Lack knowledge of the programming language
-
23. Watir with Cucumber
- 23.1 How Watir is integrated with Cucumber?
- 23.2 Execute Cucumber tests
- 23.3 Cucumber or RSpec?
- Afterword
-
Resources
- Books
- Websites
- Tools
Other books by this author
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 earnedover $14 millionwriting, 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