Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/macos-selenium-mochajs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ jobs:
working-directory: macos-selenium-mochajs
run: npm test

- name: Dump log
- name: Dump latest ChromeDriver log

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to keep non-latest logs?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be reverted, as failed chrome logging picks up the last known good log -- which is confusing.

if: always()
run: cat chromedriver.log
run: |
if [ -d "logs" ]; then
LATEST_LOG=$(ls -t logs/chromedriver-*.log 2>/dev/null | head -n 1)
if [ -n "$LATEST_LOG" ]; then
echo "Dumping $LATEST_LOG"
cat "$LATEST_LOG"
else
echo "No log files found in logs/"
fi
else
echo "logs/ directory not found"
fi
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules
node_modules/
.cache/
.idea/
logs/
4 changes: 4 additions & 0 deletions macos-selenium-mochajs/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 80,
"singleQuote": true
}
105 changes: 88 additions & 17 deletions macos-selenium-mochajs/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,99 @@
# Template for macOS, Selenium, MochaJS
# Template for Selenium, MochaJS

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template uses the latest macOS.


This repository provides a template for reproducing any ChromeDriver bug.
This repository serves as a boilerplate for reproducing ChromeDriver regressions
across platforms using Selenium WebDriver and MochaJS.

## Steps to Reproduce
Its primary purpose is to provide a standardized, isolated environment where you can
quickly set up and verify a specific ChromeDriver bug, making it easier to share and
debug.

The test in `test/regression.js` follows these steps:
## Your Goal

1. Initializes a new Chrome browser session.
2. Navigates to a URL.
3. Asserts that the page title is correct.
To use this template, you are expected to extend the `ISSUE REPRODUCTION` test case
in `test.js` with the precise steps that demonstrate the ChromeDriver regression you
are investigating. The aim is to create a reproducible test case that reliably fails
when the bug is present and passes when it's resolved.

This sequence of actions fails with ChromeDriver 126, but works with 125.
## Overview

The test script (`test.js`) performs the following actions:

1. **Environment Setup**: Automatically downloads a specific version of Chrome
(Canary by default) and the matching ChromeDriver binary into a local `.cache`
directory using `@puppeteer/browsers`.
2. **WebDriver Initialization**: Configures Selenium to use the downloaded binaries
explicitly, ensuring version compatibility.
3. **Test Execution**:
- Navigates to `https://www.google.com` to verify the setup.
- Includes a placeholder test case (`ISSUE REPRODUCTION`) where you can add your
specific reproduction steps.

## Prerequisites

- Node.js installed.

## Installation

Install the necessary dependencies:

```bash
npm install
```

## Running the Tests

1. Install dependencies:
```bash
npm install
```
2. Run the tests:
```bash
npm test
```
To run the tests with the default configuration (latest Chrome Canary):

```bash
npm test
```

### Targeting a Specific Chrome Version

You can specify a particular version of Chrome/ChromeDriver using the
`BROWSER_VERSION` environment variable. This is useful for testing against a specific
build or regression testing.

```bash
# Example: Targeting a specific build ID
BROWSER_VERSION=144.0.7557.0 npm test
```

If `BROWSER_VERSION` is not provided, the script automatically resolves and downloads

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need to mention where one needs to provide BROWSER_VERSION, preferably in a way that works across all templates. Perhaps this can be a variable in the test script itself.

the latest build from the Chrome Canary channel.

## Logging and Debugging

### Test Output Logs

The test runner uses `winston` for logging info about the setup process (e.g., binary
locations). You can control the verbosity using the `LOG_LEVEL` environment variable.

- **Standard Output:** `npm test`
- **Debug Output:** `LOG_LEVEL=debug npm test`

### ChromeDriver Logs

Verbose logging for ChromeDriver is enabled by default. Logs are captured and saved
to individual files within the **`logs/`** directory, with each filename timestamped
(e.g., `logs/chromedriver-2025-12-02T10:00:00.000Z.log`). This ensures that logs are

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't log of each run be preserved by the CI file system itself, for each run?

preserved across multiple test runs and are crucial for debugging WebDriver issues.

## Customizing the Test

Open `test.js` and modify the `ISSUE REPRODUCTION` test block to include the steps
required to reproduce your specific issue.

```javascript
it('ISSUE REPRODUCTION', async function () {
// Add test reproducing the issue here.
await driver.get('https://example.com');
// ... assertions and interactions
});
```

## GitHub Actions

The included GitHub Actions workflow in `.github/workflows/macos-selenium-mochajs.yml` will automatically run the tests on every push and pull request.
The included GitHub Actions workflow in
`.github/workflows/macos-selenium-mochajs.yml` will automatically run the tests on
every push and pull request.
Loading