0%

Book Description

Complement Selenium with useful additions that fit seamlessly into the rich and well-crafted API that Selenium offers

About This Book
  • Understand the power, simplicity, and limitations of the core Selenium framework
  • Write clear, readable, and reliable tests that perform complex test automation tasks
  • Work with ChromeDriver and GeckoDriver in headless mode
Who This Book Is For

If you are a software tester or a developer with working experience in Selenium and competency with Java, who is interested in automation and are looking forward to taking the next step in their learning journey, then this is the book for you.

What You Will Learn
  • Provide fast, useful feedback with screenshots
  • Create extensible, well-composed page objects
  • Utilize ChromeDriver and GeckoDriver in headless mode
  • Leverage the full power of Advanced User Interactions APIs
  • Use JavascriptExecutor to execute JavaScript snippets in the browser through Selenium
  • Build user interaction into your test script using JavascriptExecutor
  • Learn the basics of working with Appium
In Detail

The second edition of Mastering Selenium 3.0 WebDriver starts by showing you how to build your own Selenium framework with Maven. You'll then look at how you can solve the difficult problems that you will undoubtedly come across as you start using Selenium in an enterprise environment and learn how to produce the right feedback when failing. Next, you'll explore common exceptions that you will come across as you use Selenium, the root causes of these exceptions, and how to fix them. Along the way, you'll use Advanced User Interactions APIs, running any JavaScript you need through Selenium; and learn how to quickly spin up a Selenium Grid using Docker containers. In the concluding chapters, you'll work through a series of scenarios that demonstrate how to extend Selenium to work with external libraries and applications so that you can be sure you are using the right tool for the job.

Style and approach

This book is a pragmatic guide that takes you through the process of creating a test framework with Selenium 3. It then shows you how you can extend this framework to overcome common obstacles that you will come across whilst using Selenium.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Selenium WebDriver 3.0 Second Edition
  3. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  6. Creating a Fast Feedback Loop
    1. Making it easy for developers to run tests
    2. Building our test project with Apache Maven
    3. Running your tests in parallel
    4. Parallel tests with TestNG
    5. There are no silver bullets
    6. Multiple browser support
    7. Downloading WebDriver binaries automatically
    8. Going headless
      1. What happened to GhostDriver?
    9. Summary
  7. Producing the Right Feedback When Failing
    1. Location, location, location
    2. Tests are living documentation
    3. Reliability
      1. The test automation team that works in isolation
      2. Oh, that test always flickers – don't worry about it
    4. Baking in reliability
      1. Git
      2. Subversion
    5. Continuous integration is key
      1. Setting up TeamCity
      2. Setting up Jenkins
    6. Extending our capabilities by using a Selenium-Grid
    7. A picture paints a thousand words
    8. Don't be afraid of the big bad stack trace
    9. Summary
  8. Exceptions Are Actually Oracles
    1. NoSuchElementException
    2. NoSuchFrameException
    3. NoSuchWindowException
    4. ElementNotVisibleException
    5. StaleElementReferenceException
    6. InvalidElementStateException
    7. UnsupportedCommandException
    8. UnreachableBrowserException
    9. SessionNotFoundException
    10. WebDriverException – element is not clickable at point
    11. NoAlertPresentException
    12. Summary
  9. The Waiting Game
    1. Are we nearly ready yet?
    2. I've timed it, and I know it takes 5 seconds for the page to load
      1. Machine specification
      2. Server specification
      3. JavaScript engine performance
      4. Networks
    3. So, what do we do?
    4. I just want Selenium to do it for me
      1. Page load timeout
      2. Script timeout
      3. Implicitly wait timeout
        1. It can slow my tests down?
        2. It can break explicit waits?
          1. The explicit wait that never finds an element
          2. Hang on, I've tried this and it didn't work that way for me!
          3. The explicit wait that works, but slows your tests down
        3. The solution
    5. Using explicit waits
    6. Fluent waits, the core of explicit waits
      1. Functions
      2. Java8 lambdas
    7. Summary
  10. Working with Effective Page Objects
    1. Why do you keep repeating yourself?
    2. Starting out with page objects
    3. Separation of concerns with page objects
    4. Introducing the Java PageFactory class
      1. Using PageFactory annotations
      2. Initializing proxied objects
      3. Problems with the Java PageFactory class
    5. Introducing the Query object
    6. So, which option should I use?
    7. Creating extensible page objects
    8. Turning your page objects into a readable DSL
    9. Fluent page objects
    10. Summary
  11. Utilizing the Advanced User Interactions API
    1. Getting started with the API
    2. Using the API to solve difficult problems
      1. Working with hover menus
      2. Working with drag and drop
      3. Working with offsets
      4. Working with access keys
      5. The Advanced Interactions API doesn't always work for me
    3. Summary
  12. JavaScript Execution with Selenium
    1. Introducing the JavaScript executor
    2. Let's not get carried away
    3. So, what should we do with it?
    4. A more complex example
      1. Executing complex blocks of JavaScript with the JavascriptExecutor
    5. Can I use JavaScript libraries?
    6. Should I inject JavaScript libraries?
    7. What about asynchronous scripts?
    8. Building user interaction into your automation
    9. Summary
  13. Keeping It Real
    1. File downloads with Selenium
      1. The scenario
      2. The problem
      3. So, what's next?
      4. Do you really need to download that file?
      5. Checking that links are valid
      6. What if I do need to download the file?
        1. AutoIt
        2. Java Robot class
        3. Browser auto download
        4. Extending our existing code
      7. Downloading a file with the help of Selenium
        1. But that's not the same as clicking on a link and downloading the file
        2. Checking that the file we have downloaded is the correct one
    2. You cannot track network traffic with Selenium
    3. But I really want to track my network traffic!
    4. Writing performance tests with Selenium
    5. Penetration testing with Selenium
    6. Summary
  14. Hooking Docker into Selenium
    1. Introducing Docker
    2. Spinning up Selenium-Grid with Docker
    3. Running tests against our new Selenium-Grid
    4. Starting up Docker containers as part of the build
    5. Using a Docker Maven plugin
    6. Using Docker compose
    7. What about the negatives?
    8. Summary
  15. Selenium – the Future
    1. Machine learning — the new Holy Grail
    2. Visual validation
      1. Applitools Eyes
      2. So what has this got to do with AI?
    3. Self healing tests
    4. Having your tests written for you
    5. Summary
  16. Appendix A: Contributing to Selenium
    1. Selenium is amazing – how can I help make it better?
      1. Getting set up to contribute to a Selenium repository
      2. Aiding the documentation effort
    2. Making changes to Selenium
      1. Keeping your history clean
      2. Now it's your turn
  17. Appendix B: Working with JUnit
    1. Switching from TestNG to JUnit
    2. Summary
  18. Appendix C: Introduction to Appium
    1. Creating an Appium framework
      1. Automating the Android calculator
      2. Running the tests through Maven
      3. Starting and stopping Appium with Maven
    2. Summary
  19. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
13.58.112.1