|
1 | | -# Template for macOS, Selenium, MochaJS |
| 1 | +# Template for Selenium, MochaJS |
2 | 2 |
|
3 | | -This repository provides a template for reproducing any ChromeDriver bug. |
| 3 | +This repository serves as a boilerplate for reproducing ChromeDriver regressions |
| 4 | +across platforms using Selenium WebDriver and MochaJS. |
4 | 5 |
|
5 | | -## Steps to Reproduce |
| 6 | +Its primary purpose is to provide a standardized, isolated environment where you can |
| 7 | +quickly set up and verify a specific ChromeDriver bug, making it easier to share and |
| 8 | +debug. |
6 | 9 |
|
7 | | -The test in `test/regression.js` follows these steps: |
| 10 | +## Your Goal |
8 | 11 |
|
9 | | -1. Initializes a new Chrome browser session. |
10 | | -2. Navigates to a URL. |
11 | | -3. Asserts that the page title is correct. |
| 12 | +To use this template, you are expected to extend the `ISSUE REPRODUCTION` test case |
| 13 | +in `test.js` with the precise steps that demonstrate the ChromeDriver regression you |
| 14 | +are investigating. The aim is to create a reproducible test case that reliably fails |
| 15 | +when the bug is present and passes when it's resolved. |
12 | 16 |
|
13 | | -This sequence of actions fails with ChromeDriver 126, but works with 125. |
| 17 | +## Overview |
| 18 | + |
| 19 | +The test script (`test.js`) performs the following actions: |
| 20 | + |
| 21 | +1. **Environment Setup**: Automatically downloads a specific version of Chrome |
| 22 | + (Canary by default) and the matching ChromeDriver binary into a local `.cache` |
| 23 | + directory using `@puppeteer/browsers`. |
| 24 | +2. **WebDriver Initialization**: Configures Selenium to use the downloaded binaries |
| 25 | + explicitly, ensuring version compatibility. |
| 26 | +3. **Test Execution**: |
| 27 | + - Navigates to `https://www.google.com` to verify the setup. |
| 28 | + - Includes a placeholder test case (`ISSUE REPRODUCTION`) where you can add your |
| 29 | + specific reproduction steps. |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +- Node.js installed. |
| 34 | + |
| 35 | +## Installation |
| 36 | + |
| 37 | +Install the necessary dependencies: |
| 38 | + |
| 39 | +```bash |
| 40 | +npm install |
| 41 | +``` |
14 | 42 |
|
15 | 43 | ## Running the Tests |
16 | 44 |
|
17 | | -1. Install dependencies: |
18 | | - ```bash |
19 | | - npm install |
20 | | - ``` |
21 | | -2. Run the tests: |
22 | | - ```bash |
23 | | - npm test |
24 | | - ``` |
| 45 | +To run the tests with the default configuration (latest Chrome Canary): |
| 46 | + |
| 47 | +```bash |
| 48 | +npm test |
| 49 | +``` |
| 50 | + |
| 51 | +### Targeting a Specific Chrome Version |
| 52 | + |
| 53 | +You can specify a particular version of Chrome/ChromeDriver using the |
| 54 | +`BROWSER_VERSION` environment variable. This is useful for testing against a specific |
| 55 | +build or regression testing. |
| 56 | + |
| 57 | +```bash |
| 58 | +# Example: Targeting a specific build ID |
| 59 | +BROWSER_VERSION=144.0.7557.0 npm test |
| 60 | +``` |
| 61 | + |
| 62 | +If `BROWSER_VERSION` is not provided, the script automatically resolves and downloads |
| 63 | +the latest build from the Chrome Canary channel. |
| 64 | + |
| 65 | +## Logging and Debugging |
| 66 | + |
| 67 | +### Test Output Logs |
| 68 | + |
| 69 | +The test runner uses `winston` for logging info about the setup process (e.g., binary |
| 70 | +locations). You can control the verbosity using the `LOG_LEVEL` environment variable. |
| 71 | + |
| 72 | +- **Standard Output:** `npm test` |
| 73 | +- **Debug Output:** `LOG_LEVEL=debug npm test` |
| 74 | + |
| 75 | +### ChromeDriver Logs |
| 76 | + |
| 77 | +Verbose logging for ChromeDriver is enabled by default. Logs are captured and saved |
| 78 | +to individual files within the **`logs/`** directory, with each filename timestamped |
| 79 | +(e.g., `logs/chromedriver-2025-12-02T10:00:00.000Z.log`). This ensures that logs are |
| 80 | +preserved across multiple test runs and are crucial for debugging WebDriver issues. |
| 81 | + |
| 82 | +## Customizing the Test |
| 83 | + |
| 84 | +Open `test.js` and modify the `ISSUE REPRODUCTION` test block to include the steps |
| 85 | +required to reproduce your specific issue. |
| 86 | + |
| 87 | +```javascript |
| 88 | +it('ISSUE REPRODUCTION', async function () { |
| 89 | + // Add test reproducing the issue here. |
| 90 | + await driver.get('https://example.com'); |
| 91 | + // ... assertions and interactions |
| 92 | +}); |
| 93 | +``` |
25 | 94 |
|
26 | 95 | ## GitHub Actions |
27 | 96 |
|
28 | | -The included GitHub Actions workflow in `.github/workflows/macos-selenium-mochajs.yml` will automatically run the tests on every push and pull request. |
| 97 | +The included GitHub Actions workflow in |
| 98 | +`.github/workflows/macos-selenium-mochajs.yml` will automatically run the tests on |
| 99 | +every push and pull request. |
0 commit comments