Sample Puppeteer tests to run on BrowserStack
You can now run your Puppeteer tests on the BrowserStack infrastructure. Porting your existing Puppeteer tests to run on BrowserStack, can be done in a matter of minutes.
This guide walks you through running a sample Puppeteer test on BrowserStack and then goes on to run tests on privately hosted websites.
You need BrowserStack credentials to be able to run Puppeteer tests. You have to replace YOUR_USERNAME
and YOUR_ACCESS_KEY
in the sample scripts in this repository with your BrowserStack credentials which can be found in your Account Settings page.
Alternatively, you can set the environment variables BROWSERSTACK_USERNAME
and BROWSERSTACK_ACCESS_KEY
with your credentials and all the scripts in this repository should work fine
- Clone this repository
- Install the dependencies using
npm install
- Replace
YOUR_USERNAME
andYOUR_ACCESS_KEY
induckduckgo_search.js
with your BrowserStack credentials - Run the sample script using
node duckduckgo_search.js
- Clone this repository (if not already done)
- Install the dependencies using
npm install
(if not already done) - Replace
YOUR_USERNAME
andYOUR_ACCESS_KEY
inparallel_test.js
file, with your BrowserStack credentials - Run across 8 different browser and OS combinations in parallel using
node parallel_test.js
- You have to download the BrowserStack Local binary from the links below (depending on your local machine's environment):
- Once you have downloaded and unzipped the file, you can initiate the binary by running the command:
./BrowserStackLocal --key YOUR_ACCESS_KEY
- Once you see the terminal say “[SUCCESS] You can now access your local server(s) in our remote browser”, your local testing connection is considered established.
- You can then replace
YOUR_USERNAME
andYOUR_ACCESS_KEY
inlocal_test.js
with your BrowserStack credentials and run the sample Local test usingnode local_test.js
Puppeteer tests can be run on BrowserStack in the following browsers (including versions):
chrome
browser version72
and above across different versions of Windows and macOS operating systems mentioned below.firefox
browser version86
and above across all supported OS versions as mentioned below.edge
browser version80
and above across all supported OS versions as mentioned below.
You can use the browser_version
capability to specify the version of the browser where you want to run your tests. We support values like latest-beta
, latest
, latest-1
, latest-2
and so on, in the browser_version
capability so specify the current beta, latest or latest-n browser version to run your tests.
You can specify the browser
and browser_version
capability as follows:
('browser': 'chrome', 'browser_version': 'latest-beta'
)
- Windows 10 (
'os': 'Windows', 'os_version': '10'
) - Windows 8.1 (
'os': 'Windows', 'os_version': '8.1'
) - Windows 8 (
'os': 'Windows', 'os_version': '8'
) - Windows 7 (
'os': 'Windows', 'os_version': '7'
) - macOS Big Sur (
'os': 'osx', 'os_version': 'Big Sur'
) - macOS Catalina (
'os': 'osx', 'os_version': 'Catalina'
) - macOS High Sierra (
'os': 'osx', 'os_version': 'High Sierra'
) - macOS Sierra (
'os': 'osx', 'os_version': 'Sierra'
) - macOS El Capitan (
'os': 'osx', 'os_version': 'El Capitan'
)
While your Puppeteer session runs on BrowserStack, we generate a unique ID for the session, build and also generate URLs for the various types of logs which you can use to build your own reporting or for any other purpose that you might like.
A sample script with the use of the API to fetch all the relevant session details is shown in the sample_session_details_API.js.
You can see the documentation for marking test status using REST API using the session ID for the session, any time even after the session has completed its execution.
If you are facing any issue with any of the above or any other issue in trying to run your Puppeteer tests on BrowserStack, you can reach out to support, select product as Automate
and send us your query.