|
1 | 1 | # puppeteer-browserstack
|
2 |
| -Sample repo for Puppeteer samples with BrowserStack. |
| 2 | +Sample Puppeteer tests to run on BrowserStack |
| 3 | + |
| 4 | +## Introduction |
| 5 | + |
| 6 | +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. |
| 7 | + |
| 8 | +This guide walks you through running a sample Puppeteer test on BrowserStack and then goes on to run tests on privately hosted websites. |
| 9 | + |
| 10 | +## Pre-requisites |
| 11 | + |
| 12 | +You need BrowserStack credentials to be able to run Puppeteer tests and also you need to be included in the Beta group so that we can enable Puppeteer access for you in our infra while the integration is in closed-beta. |
| 13 | + |
| 14 | +If you have already been included in the beta group, proceed ahead. Else, you can [reach out to support](https://www.browserstack.com/contact#technical-support) to get included in the beta group. |
| 15 | + |
| 16 | +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](https://www.browserstack.com/accounts/settings) page. |
| 17 | + |
| 18 | +**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** |
| 19 | + |
| 20 | +## Run your first Playwright test on BrowserStack |
| 21 | + |
| 22 | +1. Clone this repository |
| 23 | +2. Install the dependencies using `npm install` |
| 24 | +3. Replace `YOUR_USERNAME` and `YOUR_ACCESS_KEY` in `google_search.js` with your BrowserStack credentials |
| 25 | +3. Run the sample script using `node google_search.js` |
| 26 | + |
| 27 | +## Test across multiple browser and OS versions in parallel |
| 28 | + |
| 29 | +1. Clone this repository (if not already done) |
| 30 | +2. Install the dependencies using `npm install` (if not already done) |
| 31 | +3. Replace `YOUR_USERNAME` and `YOUR_ACCESS_KEY` in `parallel_test.js` file, with your BrowserStack credentials |
| 32 | +4. Run across 8 different browser and OS combinations in parallel using `node parallel_test.js` |
| 33 | + |
| 34 | + |
| 35 | +## Run sample test on privately hosted websites |
| 36 | + |
| 37 | +1. You have to download the BrowserStack Local binary from the links below (depending on your local machine's environment): |
| 38 | + * [OS X (10.7 and above)](https://www.browserstack.com/browserstack-local/BrowserStackLocal-darwin-x64.zip) |
| 39 | + * [Linux 32-bit](https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-ia32.zip) |
| 40 | + * [Linux 64-bit](https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip) |
| 41 | + * [Windows (XP and above)](https://www.browserstack.com/browserstack-local/BrowserStackLocal-win32.zip) |
| 42 | +2. Once you have downloaded and unzipped the file, you can initiate the binary by running the command: `./BrowserStackLocal --key YOUR_ACCESS_KEY` |
| 43 | +3. 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. |
| 44 | +4. You can then replace `YOUR_USERNAME` and `YOUR_ACCESS_KEY` in `local_test.js` with your BrowserStack credentials and run the sample Local test using `node local_test.js` |
| 45 | + |
| 46 | +## Supported browser versions |
| 47 | + |
| 48 | +Puppeteer tests can be run on BrowserStack in the following browsers (including versions): |
| 49 | +1. `chrome` browser version `72` and above across different versions of Windows and macOS operating systems mentioned below. |
| 50 | +2. `firefox` browser version `86` and above across all supported OS versions as mentioned below. |
| 51 | +3. `edge` browser version `80` and above across all supported OS versions as mentioned below. |
| 52 | + |
| 53 | +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. |
| 54 | + |
| 55 | +You can specify the `browser` and `browser_version` capability as follows:<br> (`'browser': 'chrome', 'browser_version': 'latest-beta'`) |
| 56 | + |
| 57 | +### OS (with versions) supported |
| 58 | +1. Windows 10 (`'os': 'Windows', 'os_version': '10'`) |
| 59 | +2. Windows 8.1 (`'os': 'Windows', 'os_version': '8.1'`) |
| 60 | +3. Windows 8 (`'os': 'Windows', 'os_version': '8'`) |
| 61 | +4. Windows 7 (`'os': 'Windows', 'os_version': '7'`) |
| 62 | +5. macOS Big Sur (`'os': 'osx', 'os_version': 'Big Sur'`) |
| 63 | +6. macOS Catalina (`'os': 'osx', 'os_version': 'Catalina'`) |
| 64 | +7. macOS High Sierra (`'os': 'osx', 'os_version': 'High Sierra'`) |
| 65 | +8. macOS Sierra (`'os': 'osx', 'os_version': 'Sierra'`) |
| 66 | +9. macOS El Capitan (`'os': 'osx', 'os_version': 'El Capitan'`) |
| 67 | + |
| 68 | +## Get Puppeteer session details |
| 69 | + |
| 70 | +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. |
| 71 | + |
| 72 | +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](./sample_session_details_API.js). |
| 73 | + |
| 74 | +You can see the [documentation for marking test status using REST API](https://www.browserstack.com/docs/automate/api-reference/selenium/session#set-test-status) using the session ID for the session, any time even after the session has completed its execution. |
| 75 | + |
| 76 | +## Facing issues? |
| 77 | + |
| 78 | +If you are facing any issue with any of the above or any other issue in trying to run your Playwright tests on BrowserStack, you can reach out to me directly at `[email protected]` and I will be happy to debug your issues or at the least ensure that your issue becomes our top priority to resolve. |
0 commit comments