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 @pytest.mark.asyncio async def test_title(): try: browser = await pyppeteer.connect(browserWSEndpoint='wss://chrome.headlesstesting.com/?token=[YOUR-TOKEN]') page = await browser.newPage() await page.goto('https://headlesstesting.com') title = await page.title() assert title == 'Headless Testing with Puppeteer and Playwright in the Cloud.' await browser.close() except E: print(E)
This example will open a Chrome browser, navigate to our homepage and verify the document's title.
@pytest.mark.asyncio to let PyTest know that we're using
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.