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 Playwright.
import pytest from playwright import sync_playwright @pytest.fixture def browser(): pw_context = sync_playwright() pw = pw_context.__enter__() browser = getattr(pw, "chromium").connect(wsEndpoint='wss://chrome.headlesstesting.com?token=[YOUR-TOKEN]') browser._close = browser.close def _handle_close() -> None: browser._close() pw_context.__exit__(None, None, None) browser.close = _handle_close return browser def test_title(browser): page = browser.newPage() page.goto('https://headlesstesting.com') assert page.title() == 'Headless Testing with Puppeteer and Playwright in the Cloud.' browser.close()
This example will open a Chrome browser, navigate to our homepage and verify the document's title.
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.