Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Enhanced Test Automation with WebdriverIO

You're reading from   Enhanced Test Automation with WebdriverIO Unlock the superpowers of hybrid testing frameworks

Arrow left icon
Product type Paperback
Published in Nov 2023
Publisher Packt
ISBN-13 9781837630189
Length 328 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Larry C. Goddard Larry C. Goddard
Author Profile Icon Larry C. Goddard
Larry C. Goddard
Paul M. Grossman Paul M. Grossman
Author Profile Icon Paul M. Grossman
Paul M. Grossman
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Chapter 1: The Utility Belt – Tools Every Superhero SDET Needs 2. Chapter 2: Fortress of Solitude – Configuring WebdriverIO FREE CHAPTER 3. Chapter 3: Cybernetic Enhancements – WebdriverIO Config and Debug Tips 4. Chapter 4: Super Speed – Time-Travel Paradoxes and Broken Promises 5. Chapter 5: Alter Egos – The ClickAdv Wrapper 6. Chapter 6: The setValue Wrapper – Entering Text and Dynamic Data Replacement 7. Chapter 7: The Select Wrapper – Choosing Values in Lists and Comboboxes 8. Chapter 8: The Assert Wrapper – the Importance of Embedded Details 9. Chapter 9: The Ancient Spell Book – Building the Page Object Model 10. Chapter 10: Increased Flexibility – Writing Robust Selectors and Reducing Maintenance 11. Chapter 11: Echo Location – Skipping the Page Object Model 12. Chapter 12: Superhero Landing – Setting Up Flexible Navigation Options 13. Chapter 13: The Multiverses – Cross-Browser Testing and Cross-Environment Testing 14. Chapter 14: The Time-Traveler’s Dilemma – State-Driven End to End User Journeys 15. Chapter 15: The Sentient Cape – Running Tests in a CI/CD Pipeline with Jenkins and LambdaTest 16. Epilogue
17. Index 18. Other Books You May Enjoy Appendix: The Ultimate Guide to TypeScript Error Messages, Causes, and Solutions

Anatomy of an XPath selector

Selectors are comprised of one or more node tag types followed by an optional [predicate] in square brackets. The predicates have operators and functions to filter certain node matches. Lastly, they include path separators with generic axes with double colons to further refine the path of the element. This makes it more likely to find an element regardless of its location in the DOM.

XPath selectors are written as absolute or relative. This is an example of an absolute-style selector to the Find My Candy button on the Candymapper website:

public get myElement() {
  const selector: string = "/html[1]/body[1]/div[1]/div[1]/div[1]/div[13]/div[1]/div[1]/div[1]/div[2]/div[2]/a[1]";
  return $(selector);
}

Now that you have seen an absolute selector, use it only as a red flag. The point of this exercise is the fluid nature of the numeric indexes inside the square brackets. The exact location will be dynamic from release to...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime