Metadata-Version: 2.4
Name: selenium-screenshot-compare
Version: 0.1.2
Summary: Compare a website's rendering between two Firefox versions driven in parallel via Selenium (Python + Robot Framework library).
Author: EAnathos
License-Expression: MIT
Project-URL: Homepage, https://github.com/EAnathos/selenium-screenshot-compare
Project-URL: Source, https://github.com/EAnathos/selenium-screenshot-compare
Keywords: selenium,firefox,screenshot,diff,robot-framework,visual-regression
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Robot Framework :: Library
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: selenium>=4.20
Requires-Dist: Pillow>=10.0
Requires-Dist: numpy>=1.24
Provides-Extra: robot
Requires-Dist: robotframework>=7.0; extra == "robot"
Provides-Extra: dev
Requires-Dist: robotframework>=7.0; extra == "dev"
Requires-Dist: robotframework-robocop>=8.0; extra == "dev"
Requires-Dist: pre-commit>=4.0; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Dynamic: license-file

# selenium-screenshot-compare

Compare a website's rendering between **two Firefox versions** through a
click-based navigation scenario. At each step, both full-page renders are
captured and their pixel difference is measured.

Usable from **plain Python** or as a **Robot Framework** library.

## Installation

```bash
pip install selenium-screenshot-compare
```

You need two Firefox binaries (your system Firefox + a second version).
See [docs/firefox-setup.md](docs/firefox-setup.md) for how to get one.

## Quick start — Python

```python
from selenium_screenshot_compare import DualSession, compare_images

session = DualSession("/usr/bin/firefox", "./firefoxes/firefox-128esr/firefox")
session.open("https://example.com")
session.click("css=a.nav-link")
session.capture_both("a.png", "b.png")
result = compare_images("a.png", "b.png", "diff.png")
print(f"{result.percent:.2f} % difference")
session.close()
```

## Quick start — Robot Framework

```bash
pip install selenium-screenshot-compare[robot]
robot --outputdir output/robot tests/interactive_navigation.robot
```

```robotframework
Open Versions    ${SITE}    ${FIREFOX_A}    ${FIREFOX_B}
Capture And Compare    home    ${CAPTURES_DIR}
Click Element    css=a[href="/photographie"]
Capture And Compare    after-click    ${CAPTURES_DIR}
[Teardown]    Close Versions
```

## Keywords

| Keyword | Role |
|---|---|
| `Open Versions` | open the URL in both Firefox instances |
| `Go To` | navigate to a URL |
| `Click Element` | click (`css=`, `id=`, `xpath=`…) |
| `Input Text` | type text |
| `Go Back` | previous page |
| `Capture And Compare` | capture + diff + `result.json` |
| `Load Storage State` | inject cookies + localStorage (authenticated session) |
| `Close Versions` | close both browsers |

## Output

Each `Capture And Compare` produces a folder with `version_a.png`,
`version_b.png`, `diff.png`, and a `result.json`:

```json
{
  "difference_percent": 0.0,
  "first_diff_y": null,
  "firefox_a": "152.0.1",
  "firefox_b": "128.0"
}
```

## Documentation

- [Firefox setup](docs/firefox-setup.md) — getting a second Firefox binary (Linux / Windows / macOS)
- [Authenticated sessions](docs/authenticated-sessions.md) — comparing pages behind a login
- [Windows notes](docs/windows.md) — venv paths, Firefox paths, running suites
- [Contributing](CONTRIBUTING.md) — development setup, linting, CI, releasing

## License

[MIT](LICENSE)
