Transcripted Summary

In this course, we will learn how to do web UI testing in Python by building our own test automation solution from the ground up using pytest and Selenium WebDriver.

Each chapter will iteratively add a new layer to our solution so that we can learn step-by-step. By the end of the course, you will have a small but robust test project that you can extend with more tests.

However, we need to start with one test case. For this course, we will automate a basic search test for DuckDuckGo together.

Why choose DuckDuckGo?

Well, DuckDuckGo is a popular search engine with a simple interface. You enter a search phrase and get results on another page. It's easy to understand and available to anyone with an internet connection.

Anytime we want to automate new tests, we must always think before we code.



Always write tests steps before writing test code.

Otherwise, if you start coding too soon, then you might end up testing the wrong things. Well-written test cases are the starting point for well-developed test automation solutions.

Let's manually act out our basic web search test together.

Here we are at the DuckDuckGo homepage. My first step will be to load this page.

Then, I'll enter my search phrase into the search bar. Once the search goes through, the results page will be loaded.

On this results page, there are a number of elements I can use to verify that my search was successful.

  • I can look at the title of the page or maybe the URL text.

  • I could look for the search query in my search bar.

  • Moreover, I could look at all the different results and scrape their text to make sure that somehow my search phrase appears in the results.

Once I have a good understanding of the test case I want to automate, I'll write down its steps.

Personally, I like to write my tests using Gherkin.

Gherkin is a simple language for specifying behaviors and test cases. If you are familiar with behavior-driven development or BDD, then you'll recognize Gherkin.

If not, no worries. Gherkin's Given, When, Then format is intuitive by design.

Anyone can read and understand it, even developers and product owners. Writing tests in Gherkin is not a requirement, but it strongly helps me think before I code.

Here, our test case has 5 steps.



Given the DuckDuckGo homepage is displayed, When the user searches for “panda”, Then the search result title contains “panda”, And the search result query is “panda”, And the search result links pertain to “panda”.

In 5 short lines, I have a full web UI test case ready to be automated.



Resources



© 2021 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR