This repository contains examples of how to run Puppeteer tests on TestingBot's real browser cloud. With TestingBot, you can test your web applications on real browsers with different versions and operating systems.
- Node.js (v14 or newer)
- TestingBot account with API credentials (Key and Secret)
- Clone this repository:
git clone https://github.com/testingbot/puppeteer-testingbot-example.git
cd puppeteer-testingbot-example
- Install dependencies:
npm install
- Set your TestingBot credentials:
export TB_KEY="your-testingbot-key"
export TB_SECRET="your-testingbot-secret"
Run tests on different browsers:
# Run on Chrome
npm run test:puppeteer:chrome
# Run on Firefox
npm run test:puppeteer:firefox
# Run on Edge
npm run test:puppeteer:edge
Run tests using Jest:
npm run test:jest
Run tests using WebdriverIO:
npm run test:webdriverio
When running tests on TestingBot with Puppeteer, you can use various options to customize your testing environment. These options are passed in the WebSocket URL when connecting to TestingBot.
- browserName: Choose from Chrome, Edge, Firefox
- browserVersion: Specify browser version (e.g., "latest", "*", "<=16")
- platform: Select OS like WIN10, WIN11, SEQUOIA, LINUX
- screenRecorder: Enable/disable video recording (default: true)
- public: Make test results publicly accessible (default: false)
- name: Custom test name
- build: Group tests under a build identifier
- timeout: Session timeout in seconds (default: 90)
- maxDuration: Maximum test duration (default: 1800 seconds)
- timeZone: Set custom time zone
- screen-resolution: Change screen resolution
- geoCountryCode: Test from specific country
- upload: Upload files to test VM
- startupFlags: Customize browser startup flags
- blacklist: Block specific hostnames
- recordLogs: Enable/disable logging
- extra: Add custom metadata
- tunnelIdentifier: Use TestingBot Tunnel
Example usage:
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET,
name: 'Puppeteer Chrome Test'
},
browserName: 'chrome',
browserVersion: 'latest',
platform: 'WIN10',
};
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://cloud.testingbot.com/puppeteer?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
});
For a complete list of options, visit the TestingBot Puppeteer Options documentation.