Skip to main content

Puppeteer Testing With CodeceptJS


Learn how to run your Puppeteer tests with CodeceptJS across 40+ real browsers and operating systems on the LambdaTest platform.

Pre-requisites


Note: All the code samples in this documentation can be found in the LambdaTest's Repository on GitHub. You can either download or clone the repository to quickly run your tests.

Image View on GitHub
  1. Clone the puppeteer-sample repository on your system and navigate to the pytest-pyppeteer directory.
cd pytest-pyppeteer
  1. Create a virtual environment using the following commands:
virtualenv venv
source venv/bin/activate
  1. Install the necessary configurations.
poetry install
  1. Install the necessary dependencies
pip install - r requirements.txt
  1. In order to run your pyppeteer tests, you will need to set your LambdaTest username and access key in the environment variables. Click the Access Key button at the top-right of the Automation Dashboard to access it.
Image
Windows
set LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
set LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"
macOS/Linux
export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

Running Your First Pyppeteer Test

The first test script navigates to DuckduckGo and searches for LambdaTest. The second test script navigates to Brave search and searches for LambdaTest. Both the tests are executed using Chrome (latest) on Windows 11.

Once you are done with the steps 1 thru' 5, you can initiate your first Pyppeteer test on LambdaTest.

Run the following command on the terminal to run the Pyppeteer tests in parallel.

pytest --verbose --capture=no -s -n 2 tests/test_pytest_pyppeteer_1.py \
tests/test_pytest_pyppeteer_2.py

View your Pyppeteer test results

The LambdaTest Automation Dashboard is where you can see the results of your Pyppeteer tests after running them on the LambdaTest platform.

The below screenshot of LambdaTest Automation Dashboard shows the pyppeteer build on the left and the build sessions associated with the selected build on the right.

Pyppeteer LambdaTest Dashboard

On clicking the session name of the respective test, you can view the details of pyppeteer test session that you just executed. For example, the below screenshot shows a test execution details of pyppeteer test like Test Name, Test ID, selected configurations, test logs, basic info, input config, and test session video.

Pyppeteer LambdaTest Test View

Run Pyppeteer Tests In Gitpod

Select the button below to try this demo in Gitpod

Run in Gitpod

  • After the Gitpod session launches, navigate to the terminal and run the following commands to save your LambdaTest Credentials to Gitpod as environment variables:
eval $(gp env -e LT_USERNAME=******)
eval $(gp env -e LT_ACCESS_KEY=******)
  • Click the following link if you're unsure how to access your LambdaTest credentials.. Also, if you start a new terminal in Gitpod, you have to run the following command to reset environment variables:
 eval $(gp env -e)