Selenium & qawa
Last modified on Mon 11 Jul 2022

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.


qawa stands for QA Web Automation.

Page object model

qawa uses POM (page object model), also called the page object pattern.

Read up on it here.

Installing Selenium and webdrivers

  1. Install Homebrew (and Python 3 if it is not installed)
  2. Install Selenium: pip3 install selenium
  3. Install ChromeDriver (for Chrome): brew install chromedriver
  4. Install geckodriver (for Firefox): brew install geckodriver

Example of a page class

from base_page import BasePage
from import By

class BlogPage(BasePage):

slug = "/blog"
blog_name_label_locator = (By.CLASS_NAME, "blog-intro__heading")

def navigate_to_page(self):

def blog_name_label(self):
    return self.get_present_element(self.blog_name_label_locator)

def wait_for_blog_page_to_load(self):

Example of a test class

import pytest
from logging import info
from pages.blog_page import BlogPage
from pages.home_page import HomePage
import pytest_check as check

class TestBlog:

def set_up(self, driver, environment):
    self.blog_page = BlogPage(driver, environment)
    self.home_page = HomePage(driver, environment)


def test_navigate_to_blog_page(self, set_up, extra):
    info("Navigates to blog posts and verifies that the blog title is correct.")

    check.is_true(self.blog_page.blog_name_label.text == "Typing as we speak")

Writing assertions

You can use either Python's standard assert (hard assert) or soft asserts using the pytest_check plugin. You can read more about hard and soft asserts in this handbook article.

Python's standard assert examples

Checking that the button exists:

assert == True

Checking that the button text equals the expected value:

assert == "Logout"

Soft assert examples

Here are some examples of assertion methods from the pytest_check plugin. The plugin has to be imported into the test modules in order to be used.

Checking that the button exists:


Checking that the button does not exist:


Checking that the button text equals the expected value:

pytest_check.equal(, "Logout")

Checking that the button text does not equal the expected value:

pytest_check.not_equal(, "Logout")

Additional resources