Selenium WebDriver Recipes in Ruby

 Selenium WebDriver Recipes in Ruby

The problem solving guide to Selenium WebDriver in Ruby Zhimin Zhan

This book is for sale at This version was published on 2022-10-22

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. ? 2013 - 2022 Zhimin Zhan

To Dominic and Courtney!

Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i Who should read this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii How to read this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii Recipe test scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii Send me feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii

1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Selenium language bindings: Java, C#, JavaScript, Python and Ruby . . . . 1 1.2 Cross-browser testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3 RSpec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4 Run recipe scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2. Locating web elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.1 Start browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2 Inspect Web Element in Browser . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.3 Find element by ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.4 Find element by Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.5 Find element by Link Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.6 Find element by Partial Link Text . . . . . . . . . . . . . . . . . . . . . . . . 18 2.7 Find element by XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.8 Find element by Tag Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.9 Find element by Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.10 Find element by CSS Selector . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.11 Find element by Relative locators . . . . . . . . . . . . . . . . . . . . . . . . 21 2.12 Chain find_element to find child elements . . . . . . . . . . . . . . . . . . . 21 2.13 Find multiple elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.14 Locate a Web Element that disappears after Inspect . . . . . . . . . . . . . . 22

3. Hyperlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

CONTENTS

3.1 Click a link by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.2 Click a link by ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.3 Click a link by partial text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.4 Click a link by XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.5 Click Nth link with exact same label . . . . . . . . . . . . . . . . . . . . . . . 25 3.6 Verify a link is present or not? . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.7 Getting link data attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.8 Test links open a new browser window . . . . . . . . . . . . . . . . . . . . . 27

4. Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4.1 Books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4.2 websites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.3 Blog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.4 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download