Skip to content

hubzaj/advertisements-test

Repository files navigation

Advertisements Test

Background

Here is an illustrative end-to-end (E2E) test framework designed to validate the appearance of an advertisement on the client side. In this example, we can assume we are operating within an SSP (Supply-Side Platform) company responsible for delivering ads to publishers.

Please note that this is a hypothetical scenario, and for the purposes of this example, we are not sending ad requests to the SSP. Instead, a few sample ads (hardcoded in the source code here) are defined and placed on the page.

The simplified flow, from delivering to displaying the ad, is illustrated in the example below.

Image

This project focuses specifically on the last part - ad display. The SSP delivers the ad, which is then displayed on the user's page, as depicted in the image below. A successfully displayed ad must send all the notifications attached during the delivery chain by all related companies involved in monetization.

Image

The primary responsibility of this framework is to validate if all the required requests have been sent after the successful display of the ad. To intercept and collect all incoming requests (notifications sent by the ad markup placed and fired on the page in the web browser), I opted to use selenium-wire. This choice was made because pure Selenium, along with its BiDi implementation of CDP, does not support network interception for Python due to constraints in mixing certain asynchronous and synchronous commands.

How to build project

Requirements:

  • Python ^3.11
    
  • Poetry ^1.8.2
    

How to run

  • Execute from your preferred IDE (PyCharm is recommended). Tests are located in the tests/ directory.
  • Execute from the command line using the make command, e.g., poetry run browser-tests.
  • Execute from the command line, e.g., poetry run pytest -n auto -m browser.
  • [CI/CD] Tests can also be run on a Kubernetes cluster as a job. This is useful when the entire infrastructure (devint/qa/prod environments) relies on Kubernetes.
    • Additionally, you can experiment with it on your local machine by using minikube.
    • Kubernetes configuration is managed using Helm Charts.

Working with terminal

  1. Install asdf with required plugins.
 > brew install asdf
 > asdf plugin-add python
 > asdf plugin-add poetry
 > asdf install

Configuration

Configuration is designed in a way to be controlled by environment variables.

[BROWSER]
Default:
  • Browser: Chrome

Supported browsers:

  • CHROME

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published