---
title: PyTest and Puppeteer Testing | TestingBot
description: Run PyTests on Chrome and Edge with Puppeteer. Use pyppeteer and pytest-asyncio
  on a browser grid.
source_url:
  html: https://testingbot.com/support/web-automate/puppeteer/pytest
  md: https://testingbot.com/support/web-automate/puppeteer/pytest/index.md
---
# Puppeteer & PyTest

`pytest-pyppeteer` is a Python framework to use with Puppeteer.   
 Together with `pytest-asyncio`, you can write asynchronous PyTest tests which connect to the TestingBot browser grid. Run tests in parallel on the TestingBot browser grid 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 Pyppeteer on their [documentation pages](https://miyakogi.github.io/pyppeteer/).

## Example

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

    import pytest
    import pyppeteer
    
    @pytest.mark.asyncio
    async def test_title():
      try:
        browser = await pyppeteer.connect(browserWSEndpoint='wss://cloud.testingbot.com?key=API_KEY&secret=API_SECRET&browserName=chrome&browserVersion=latest')
    
        page = await browser.newPage()
        await page.goto('https://testingbot.com')
        title = await page.title()
        assert title == 'Cross Browser Testing and Mobile App Testing | TestingBot'
        await browser.close()
      except Exception as E:
        print(E)

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

We use `@pytest.mark.asyncio` to let PyTest know that we're using `await`.   
 Please see [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) for more information about event loops, awaits and fixtures.

## Specifying browser and version

To specify on which browser and version your PyTest + Puppeteer test should run, you can include both a `browserName` and `browserVersion` in the `browserWSEndpoint` URL.

  ![OS selected](https://testingbot.com/assets/environments/svg/windows11-0e1b28bc0fdd5034d3e4d3dc8d346c500a8c6522facf4b45d0da56537c1f1c6d.svg) Windows 11 › ![Browser selected](https://testingbot.com/assets/environments/svg/chrome-c4081ff447d2d898d4afcb8f074a907c960e6f007716c1a1d119eee6803c4042.svg) Chrome 139 

Loading environments...

Please wait while we load the available browsers and platforms.

    

## 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](https://pypi.org/project/pytest-parallel/).

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
