PyTest & Puppeteer

PyTest and Pyppeteer are a great combination to do Headless Testing with Python.
Together with pytest-asyncio, you can write asynchronous PyTest tests which connect to the HeadlessTesting browser grid. Run tests in parallel on our browsers with PyTest, Pyppeteer and pytest-asyncio.

To get started, please install these packages:

pip install pytest-asyncio pyppeteer

Now you're ready to use Python with Puppeteer. There's some more information about Pypeteer on their documentation pages.


To get started, please see this simple example below.
This will start a new Chrome browser in the HeadlessTesting grid, and allow PyTest to control the browser via Puppteer.

import pytest
import pyppeteer

async def test_title():
    browser = await pyppeteer.connect(browserWSEndpoint='wss://[YOUR-TOKEN]')

    page = await browser.newPage()
    await page.goto('')
    title = await page.title()
    assert title == 'Headless Testing with Puppeteer and Playwright in the Cloud.'
    await browser.close()
  except E:

This example will open a Chrome browser, navigate to our homepage and verify the document's title.

We use @pytest.mark.asyncio to let PyTest know that we're using await.
Please see pytest-asyncio for more information about event loops, awaits and fixtures.

Parallel Testing with Pytest

One of the great advantages of our service is that you can run multiple tests simultaneously (in parallel).
This drastically shortens the total duration of your test suite, as multiple tests will run concurrently.

We recommend using pytest-parallel.