|
| 1 | +# Puppeteer TestingBot Example |
| 2 | + |
| 3 | +This repository contains examples of how to run [Puppeteer](https://pptr.dev/) tests on [TestingBot](https://testingbot.com)'s real browser cloud. With TestingBot, you can test your web applications on real browsers with different versions and operating systems. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Node.js (v14 or newer) |
| 8 | +- TestingBot account with API credentials (Key and Secret) |
| 9 | + |
| 10 | +## Setup |
| 11 | + |
| 12 | +1. Clone this repository: |
| 13 | +```bash |
| 14 | +git clone https://github.com/yourusername/puppeteer-testingbot-example.git |
| 15 | +cd puppeteer-testingbot-example |
| 16 | +``` |
| 17 | + |
| 18 | +2. Install dependencies: |
| 19 | +```bash |
| 20 | +npm install |
| 21 | +``` |
| 22 | + |
| 23 | +3. Set your TestingBot credentials: |
| 24 | +```bash |
| 25 | +export TB_KEY="your-testingbot-key" |
| 26 | +export TB_SECRET="your-testingbot-secret" |
| 27 | +``` |
| 28 | + |
| 29 | +## Running the examples |
| 30 | + |
| 31 | +### Puppeteer Examples |
| 32 | + |
| 33 | +Run tests on different browsers: |
| 34 | + |
| 35 | +```bash |
| 36 | +# Run on Chrome |
| 37 | +npm run test:puppeteer:chrome |
| 38 | + |
| 39 | +# Run on Firefox |
| 40 | +npm run test:puppeteer:firefox |
| 41 | + |
| 42 | +# Run on Edge |
| 43 | +npm run test:puppeteer:edge |
| 44 | +``` |
| 45 | + |
| 46 | +### Jest Example |
| 47 | + |
| 48 | +Run tests using Jest: |
| 49 | + |
| 50 | +```bash |
| 51 | +npm run test:jest |
| 52 | +``` |
| 53 | + |
| 54 | +### WebdriverIO Example |
| 55 | + |
| 56 | +Run tests using WebdriverIO: |
| 57 | + |
| 58 | +```bash |
| 59 | +npm run test:webdriverio |
| 60 | +``` |
| 61 | + |
| 62 | +## TestingBot Options |
| 63 | + |
| 64 | +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. |
| 65 | + |
| 66 | +### Basic Settings |
| 67 | + |
| 68 | +- **browserName**: Choose from Chrome, Edge, Firefox |
| 69 | +- **browserVersion**: Specify browser version (e.g., "latest", "*", "<=16") |
| 70 | +- **platform**: Select OS like WIN10, WIN11, SONOMA |
| 71 | + |
| 72 | +### Test Configuration |
| 73 | + |
| 74 | +- **screenRecorder**: Enable/disable video recording (default: true) |
| 75 | +- **public**: Make test results publicly accessible (default: false) |
| 76 | +- **name**: Custom test name |
| 77 | +- **build**: Group tests under a build identifier |
| 78 | +- **timeout**: Session timeout in seconds (default: 90) |
| 79 | +- **maxDuration**: Maximum test duration (default: 1800 seconds) |
| 80 | + |
| 81 | +### Environment Customization |
| 82 | + |
| 83 | +- **timeZone**: Set custom time zone |
| 84 | +- **screen-resolution**: Change screen resolution |
| 85 | +- **geoCountryCode**: Test from specific country |
| 86 | +- **upload**: Upload files to test VM |
| 87 | +- **startupFlags**: Customize browser startup flags |
| 88 | + |
| 89 | +### Additional Options |
| 90 | + |
| 91 | +- **blacklist**: Block specific hostnames |
| 92 | +- **recordLogs**: Enable/disable logging |
| 93 | +- **extra**: Add custom metadata |
| 94 | +- **tunnelIdentifier**: Use TestingBot Tunnel |
| 95 | + |
| 96 | +Example usage: |
| 97 | + |
| 98 | +```javascript |
| 99 | +const browser = await puppeteer.connect({ |
| 100 | + browserWSEndpoint: `wss://${TB_KEY}:${TB_SECRET}@cloud.testingbot.com/puppeteer?browserName=chrome&browserVersion=latest&platform=WIN10&name=My%20Test&build=Build123&screenRecorder=true&timeZone=America/New_York&screen-resolution=1920x1080` |
| 101 | +}); |
| 102 | +``` |
| 103 | + |
| 104 | +For a complete list of options, visit the [TestingBot Puppeteer Options documentation](https://testingbot.com/support/puppeteer/options.html). |
| 105 | + |
| 106 | +## GitHub Actions Integration |
| 107 | + |
| 108 | +This repository includes a GitHub Actions workflow that runs the Chrome test on TestingBot. To use it, add your TestingBot credentials as GitHub secrets: |
| 109 | + |
| 110 | +1. Go to your GitHub repository settings |
| 111 | +2. Navigate to Secrets > Actions |
| 112 | +3. Add two secrets: |
| 113 | + - `TB_KEY`: Your TestingBot key |
| 114 | + - `TB_SECRET`: Your TestingBot secret |
| 115 | + |
| 116 | +## Learn More |
| 117 | + |
| 118 | +- [TestingBot Documentation](https://testingbot.com/support) |
| 119 | +- [Puppeteer Documentation](https://pptr.dev/) |
| 120 | +- [Jest Documentation](https://jestjs.io/) |
| 121 | +- [WebdriverIO Documentation](https://webdriver.io/) |
0 commit comments