Skip to main content
No Result Found

Puppeteer testing on BrowserStack

A quickstart guide to running your Puppeteer tests across 100+ desktop browsers on BrowserStack.

Quickstart

Running your first Puppeteer test suite on BrowserStack is super easy. Here’s a quick start guide to help you get started with Puppeteer testing on BrowserStack in under 2 minutes.

Step 1: Clone our sample repository and install dependencies

All our sample tests are available on this GitHub repository. The first step is to download this repository on your system and install the dependencies as shown below:

terminal
Copy icon Copy

Step 2: Configuring BrowserStack credentials

Note: Testing on BrowserStack requires username and access key that can be found in account settings.
If you have not created an account yet, you can sign up for a Free Trial or purchase a plan.

All our sample scripts need your BrowserStack credentials to run. Please set the environment variables BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY with your credentials as shown below:

terminal
Copy icon Copy

Alternatively, your can put your credentials in the browserstack.username and browserstack.accessKey capabilities in the duckduckgo_search.js file (and all other files) in the sample repository.

Step 3: Run your first test

After you have configured the credentials and installed the npm dependencies, you can invoke your first Puppeteer test on BrowserStack using the following:

terminal
Copy icon Copy

Step 4: View your test results on the Automate Dashboard

After the test has run, you can access the test results on the BrowserStack Automate dashboard. You can learn more about viewing test results on Automate Dashboard.

Details of your first test

In this section, we will walk you through the details of the first test that you just ran and also explain the changes that you need to make in your existing Puppeteer scripts to make them run on BrowserStack.

The sample script that has run, is shown below (see in GitHub):

duckduckgo_search.js
Copy icon Copy
Note: Puppeteer tests run on BrowserStack using a client-server architecture. So, test assertions run on the client side and hence BrowserStack won’t know whether your tests have passed or failed. Learn more how to mark tests as passed or failed on BrowserStack.

You can learn more about how to make your existing Puppeteer scripts run on BrowserStack and you can also learn about how to test against your privately hosted websites.

Next Steps

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle