0.38.0: pin invisible-core 49.46.0, uv as the way in (#366)

The pin moves to invisible-core 49.46.0. The desktop settings a page can read (scrollbars, text scale, drag threshold, double-click selection, the system colours in both schemes, the refresh rate, the form-control font) are now declared by the persona instead of read from the machine it runs on.

The way in is uv: the README has one complete install block per system, and CI refuses an install instruction that is not uv. A remedy the package prints (a broken pin, an old core) is now the command for the environment it runs in, so a uv venv, which has no pip, is told the uv command.

The guides and the issue template move to uv too, and the release e2e runs the README block as written in a clean home. The tests that build prefs outside a session now declare a timezone, which 49.46.0 asks for.
This commit is contained in:
Federico Elia authored and GitHub committed 2026-10-17 13:39:46 -07:00
1 parent 9927c974da
commit 1504d95ed3
63 files changed
+518 -229

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ body:
id: install_cmd
attributes:
label: How you installed
placeholder: pip install invisible_playwright
placeholder: uv add invisible-playwright
validations:
required: true
+31 -1
View File
@@ -86,6 +86,32 @@ jobs:
python -m invisible_core.claims --selftest
python -m invisible_core.claims
# The way in is uv (the owner, 2026-09-06 and "uv everywhere" on 2026-10-17),
# and on that day this repository still taught pip in its README, its
# CONTRIBUTING, its docs and the messages its code prints, with nothing
# comparing any of them with the decision. `invisible_core.way_in` since core
# 49.45.0 refuses an install instruction that is not uv, in the tracked
# Markdown, the issue templates and the string literals of src/.
way-in:
name: every install instruction is uv
needs: core-on-index
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: install the pinned core, which carries the gate
run: |
python -m pip install --upgrade pip
pip install -e .
- name: check the way in
# --selftest first: a check that has only ever printed "clean" may
# have gone blind.
run: |
python -m invisible_core.way_in --selftest
python -m invisible_core.way_in
# `pip install -e ".[dev]"` below resolves `invisible-core==N.M.0` from the
# package index. The core is published BEFORE this package, so between the
# first push of this repo and that upload there is a window in which no
@@ -266,7 +292,7 @@ jobs:
# exits 1 without saying which of five inputs went red is a gate somebody has
# to open five tabs to read.
gate:
needs: [core-on-index, unit, docs-api, english, claims, version]
needs: [core-on-index, unit, docs-api, english, claims, version, way-in]
if: always()
runs-on: ubuntu-latest
steps:
@@ -277,6 +303,7 @@ jobs:
echo "docs-api: ${{ needs.docs-api.result }}"
echo "english: ${{ needs.english.result }}"
echo "claims: ${{ needs.claims.result }}"
echo "way-in: ${{ needs.way-in.result }}"
echo "version: ${{ needs.version.result }}"
case "${{ needs.unit.result }}" in
failure|cancelled) echo "the suite did not pass"; exit 1 ;;
@@ -293,6 +320,9 @@ jobs:
case "${{ needs.claims.result }}" in
failure|cancelled) echo "the README promises what no measurement supports"; exit 1 ;;
esac
case "${{ needs.way-in.result }}" in
failure|cancelled) echo "an install instruction is not uv"; exit 1 ;;
esac
case "${{ needs.version.result }}" in
failure|cancelled) echo "the version this change proposes is already taken"; exit 1 ;;
esac
+9 -5
View File
@@ -15,12 +15,16 @@
# * installing a blessed `playwright==<pin>` afterwards REPAIRS the venv. If
# the declared range resolves to a client the shipped Juggler cannot speak,
# that manual line turns the job green while every fresh install is broken.
# What a user gets is what pip resolves from the declaration, and that is
# what has to be under test.
# What a user gets is what the installer resolves from the declaration,
# and that is what has to be under test.
#
# So this workflow installs nothing from the checkout except the test files. It
# takes `pip install invisible-playwright` from the index, in an empty venv, and
# runs it the way somebody's first script would.
# So this workflow installs nothing from the checkout except the test files.
# test_release_e2e.py runs the README's install block for the runner's system
# as written - uv from its own installer, `uv init`, `uv add
# invisible-playwright` from the index, `fetch` - and then drives the browser
# from the project it made, the way somebody's first script would.
# test_upgrade_e2e.py stays on pip on purpose: it is the path of the people who
# installed before the README said uv, and they are still there.
#
# WHY IT MUST NOT BE MADE TOLERANT.
# There is a real window in which this cannot pass: between publishing the core
+27
View File
@@ -6,6 +6,33 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [Unreleased]
## [0.38.0] - 2026-10-17
The pin moves to invisible-core 49.46.0. The desktop settings a page can read -
scrollbars, text scale, drag threshold, double-click selection, the system
colours in both schemes, the refresh rate, the form-control font and more -
are declared by the persona instead of read from the machine it runs on, and
each of them can be pinned ([pinning](docs/pinning.md)).
### Changed
- **The way in is uv.** The README installs with one complete block per
system: uv from its own installer, `uv init --python ">=3.11" my-project`,
`uv add invisible-playwright`, `uv run invisible-playwright fetch`.
CONTRIBUTING, the guides and the issue template teach the same, and CI
refuses an install instruction that is not uv
(`python -m invisible_core.way_in`, core 49.45.0).
- **A remedy this package prints is the command for your environment.** In a
venv uv made, which has no pip, a broken install was told to run
`pip install --force-reinstall invisible-playwright`; it is now told the uv
command, and an environment pip made is still told pip, through its own
interpreter.
### Fixed
- The Docker guide's base image has a Python older than this package needs,
and the arm64 guide's Debian image an externally managed one, so neither
install line could work: uv now brings the interpreter. The installation
guide no longer lists macOS, which has had no engine since 2026-08-26.
## [0.37.0] - 2026-10-17
The pin moves to invisible-core 49.44.0, on the firefox-49 engine.
+12 -12
View File
@@ -4,8 +4,7 @@ Thanks for your interest in improving this project. Contributions are welcome vi
## Quick links
- **Bug?** Open a [bug report](https://github.com/feder-cr/invisible_playwright/issues/new?template=bug_report.yml).
- **Idea?** Open a [feature request](https://github.com/feder-cr/invisible_playwright/issues/new?template=feature_request.yml).
- **Bug or idea?** Open an [issue](https://github.com/feder-cr/invisible_playwright/issues/new/choose).
- **Security issue?** Do **not** open a public issue - see [SECURITY.md](SECURITY.md).
- **The C++ patches** live in the companion repo [feder-cr/firefox_antidetect_patch](https://github.com/feder-cr/firefox_antidetect_patch) (branch `stealth/151`). Bugs in fingerprint spoofing usually belong there.
@@ -13,11 +12,12 @@ Thanks for your interest in improving this project. Contributions are welcome vi
This repository ships the **Python wrapper** (`invisible_playwright`) around a pre-built patched Firefox. In scope:
- The `InvisiblePlaywright` sync/async API and launcher
- The fingerprint sampler (`_fpforge`)
- Binary download/caching, CLI, proxy plumbing
- The `InvisiblePlaywright` sync and async API, and its Playwright compatibility layer
- The CLI (`invisible-playwright fetch`, `invisible-playwright version`)
- Tests, docs, examples, packaging
The fingerprint, the engine download and the browser protocol client are shared by every wrapper and live in [invisible_core](https://github.com/feder-cr/invisible_core).
Out of scope (belongs in `firefox_antidetect_patch`):
- Changes to the Firefox C++ source
@@ -26,19 +26,19 @@ Out of scope (belongs in `firefox_antidetect_patch`):
## Development setup
To *use* the package you do not need any of this: `pip install invisible-playwright`.
The steps below are for working on the code.
To *use* the package you do not need any of this: see [Install](README.md#install) in the README.
The steps below are for working on the code, with [uv](https://docs.astral.sh/uv/).
```bash
git clone https://github.com/feder-cr/invisible_playwright.git
cd invisible_playwright
python -m venv .venv
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
python -m invisible_playwright fetch # download the patched Firefox binary
uv pip install -e ".[dev]"
invisible-playwright fetch # download the patched Firefox binary
```
Requires Python 3.11+ and one of: Windows x86_64, Linux x86_64.
One of: Windows x86_64, Linux x86_64 / arm64.
## Running tests
@@ -72,7 +72,7 @@ Before opening, please:
Include:
- OS and version, Python version, `invisible_playwright` version (`invisible_playwright version`)
- OS and version, Python version, the output of `invisible-playwright version`
- A minimal reproduction
- Expected vs actual behavior
- Relevant logs / stack traces
+21 -4
View File
@@ -31,15 +31,32 @@ Anti-bots ask two questions, and reCAPTCHA, hCaptcha and Cloudflare Turnstile sc
## Install
```bash
pip install invisible-playwright
python -m invisible_playwright fetch # one-time download, sha256-verified: 240 MB (Windows) / 262 MB (Linux x86_64) / 253 MB (Linux arm64), about 550 MB unpacked
Windows, in PowerShell:
```powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
$env:Path = "$env:USERPROFILE\.local\bin;$env:Path"
uv init --python ">=3.11" my-project
cd my-project
uv add invisible-playwright
uv run invisible-playwright fetch # one-time download, sha256-verified: 240 MB, about 550 MB unpacked
```
Requires **Python 3.11 or newer**.
Linux:
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
uv init --python ">=3.11" my-project
cd my-project
uv add invisible-playwright
uv run invisible-playwright fetch # one-time download, sha256-verified: 262 MB (x86_64) / 253 MB (arm64), about 550 MB unpacked
```
Supported platforms: **Windows x86_64**, **Linux x86_64 / arm64**.
Then save one of the examples below as `main.py` in `my-project` and run it with `uv run main.py`.
---
## Usage
@@ -119,7 +119,8 @@ step so the download never lands on a request path:
```dockerfile
FROM python:3.12-slim
RUN pip install invisible-playwright
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
RUN uv pip install --system invisible-playwright
# Unpack the engine at BUILD time, not per request.
RUN python -m invisible_playwright fetch
# ... your worker entrypoint ...
+1 -1
View File
@@ -141,7 +141,7 @@ Playwright method works unchanged because there is no wrapped subset to learn.
Install is the ordinary way, and the engine downloads itself on first use:
```bash
pip install invisible-playwright
uv add invisible-playwright
```
That is the engine layer, in full, scriptable. What it does not print is a
+1 -1
View File
@@ -112,7 +112,7 @@ The launch is the same two lines for both agents. The seed makes the identity
reproducible, so a failing run can be replayed rather than guessed at.
```bash
pip install invisible-playwright
uv add invisible-playwright
```
A DOM-reading agent reads structure and acts on a selector:
+1 -1
View File
@@ -97,7 +97,7 @@ a Playwright page directly. Because invisible_playwright hands you a genuine
Playwright `Page`, the port attaches to it with no adapter:
```bash
pip install invisible-playwright python-ghost-cursor
uv add invisible-playwright python-ghost-cursor
```
```python
+2 -1
View File
@@ -113,8 +113,9 @@ time, so point it at a persisted path:
```dockerfile
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
RUN pip install invisible-playwright
RUN uv pip install --system invisible-playwright
# keep the cached engine on a mounted volume so it downloads once
ENV INVISIBLE_PLAYWRIGHT_CACHE_DIR=/engines
+1 -1
View File
@@ -116,7 +116,7 @@ Switching from stock Playwright is the launch line; every method after it is sta
Playwright. Install it first:
```bash
pip install invisible-playwright
uv add invisible-playwright
```
Then gather ICE candidates through the proxy and assert the positive form. The `seed`
@@ -95,7 +95,7 @@ Strip everything that is not part of the number, then parse the digits and separ
with the page's locale rather than guessing. Babel does the locale-aware step:
```bash
pip install babel
uv add babel
```
```python
@@ -127,7 +127,7 @@ Relative and localized dates need the page's language to read the words and the
timezone to anchor the arithmetic. `dateparser` takes both:
```bash
pip install dateparser
uv add dateparser
```
```python
@@ -93,7 +93,7 @@ the main content block and discard the rest. The `readability-lxml` package is
a direct port of the well-known algorithm and takes an HTML string:
```bash
pip install readability-lxml lxml
uv add readability-lxml lxml
```
```python
@@ -69,11 +69,12 @@ Chromium-specific plumbing you have to translate.
```dockerfile
FROM python:3.11-slim
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN uv pip install --system --no-cache -r requirements.txt
# Bake the patched engine into the image at build time, not at container
# start. This is a one-time ~238 MB download (~544 MB unpacked), sha256-verified
@@ -92,7 +93,7 @@ invisible-playwright
That builds and runs. It also, by itself, still describes a machine with no GPU, a
tiny font set and no audio device, for the reason above: none of those come from
`pip install`, they come from the base image. The next two sections are what actually
the package install, they come from the base image. The next two sections are what actually
changes that.
## The part a Dockerfile cannot fix by itself
@@ -51,7 +51,7 @@ The launch is stock Playwright. If you have driven Playwright before, the only c
the two lines that open the browser:
```bash
pip install invisible-playwright
uv add invisible-playwright
```
```python
@@ -53,7 +53,7 @@ already in it. Wrap that string in `io.StringIO` (pandas asks for a file-like ob
literal HTML) and pass it in.
```bash
pip install invisible-playwright pandas lxml
uv add invisible-playwright pandas lxml
```
```python
@@ -259,7 +259,7 @@ port and that you confirm the exit inside the browser rather than assuming it. A
minimal install for the container it runs in:
```bash
pip install invisible-playwright
uv add invisible-playwright
```
The engine downloads and caches itself on first use, so the first run in a fresh
@@ -165,7 +165,8 @@ scheduler calls it. A minimal container runs the job and exits:
```dockerfile
FROM python:3.12-slim
RUN pip install invisible-playwright
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
RUN uv pip install --system invisible-playwright
COPY monitor.py .
CMD ["python", "monitor.py"]
```
@@ -10,8 +10,8 @@ nav_order: 7
# How to use invisible_playwright in Docker
To run `invisible_playwright` in Docker, start from a maintained Playwright
base image for the OS-level shared libraries, `pip install
invisible-playwright`, fetch the patched Firefox engine at build time, and
base image for the OS-level shared libraries, install
`invisible-playwright` with uv, fetch the patched Firefox engine at build time, and
run the container with `--shm-size=1gb`. The fingerprint itself needs
nothing container-specific: the same seed produces the same machine on a
desktop or inside a container.
@@ -39,6 +39,7 @@ packages that may not match your distro:
```dockerfile
FROM mcr.microsoft.com/playwright/python:v1.47.0-jammy
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
WORKDIR /app
```
@@ -50,17 +51,21 @@ libraries, not the browsers it ships alongside them.
## Installing invisible-playwright
Installing `invisible-playwright` in a container is the same two-step
install as on a desktop: `pip install invisible-playwright` for the
package, then a separate `fetch` step to download the patched engine. See
[installation](installation.md) for why the two steps are kept separate:
Installing `invisible-playwright` in a container takes the same two steps
as on a desktop: install the package with uv, then a separate `fetch` step
to download the patched engine. See [installation](installation.md) for why
the two steps are kept separate:
```dockerfile
RUN pip install --no-cache-dir invisible-playwright
RUN uv venv --python ">=3.11" /opt/venv
ENV VIRTUAL_ENV=/opt/venv PATH="/opt/venv/bin:$PATH"
RUN uv pip install --no-cache invisible-playwright
```
Nothing container-specific here yet. The wheel is small; the part that
needs a build-time decision is the next step.
The venv is not decoration: the Python in this base image is 3.10, older
than the 3.11 the package needs, so uv brings an interpreter that can run it.
The wheel is small; the part that needs a build-time decision is the next
step.
## Fetching the patched engine at build time
+1 -1
View File
@@ -93,7 +93,7 @@ a browser and read back what the server saw. A public HTTP/2 fingerprint endpoin
the frames it received as JSON.
```bash
pip install "httpx[http2]"
uv add "httpx[http2]"
```
```python
+12 -18
View File
@@ -1,6 +1,6 @@
---
title: "Installation"
description: "Install the wrapper from PyPI, then fetch the patched Firefox binary separately - a one-time, sha256-verified download. Supported on Windows, Linux and macOS."
description: "Install the wrapper with uv, then fetch the patched Firefox binary separately - a one-time, sha256-verified download. Supported on Windows and Linux."
parent: "Documentation"
nav_order: 1
---
@@ -8,31 +8,27 @@ nav_order: 1
# Installation
Install invisible-playwright in two steps: `pip install invisible-playwright` for
the Python wrapper, then `python -m invisible_playwright fetch` to download the
Install invisible-playwright in two steps: `uv add invisible-playwright` for
the Python wrapper, then `uv run invisible-playwright fetch` to download the
patched Firefox binary it drives. The steps are separate on purpose - the Python
package is small, the browser is not.
```bash
pip install invisible-playwright
python -m invisible_playwright fetch # one-time ~238 MB download (~544 MB unpacked), sha256-verified
uv add invisible-playwright
uv run invisible-playwright fetch # one-time ~238 MB download (~544 MB unpacked), sha256-verified
```
`pip install` gets you the wrapper and its API. `fetch` downloads the patched Firefox
If you do not have a uv project yet, [the README's install steps](https://github.com/feder-cr/invisible_playwright#install) create one.
`uv add` gets you the wrapper and its API. `fetch` downloads the patched Firefox
binary itself, verifies it against a sha256 shipped inside `invisible-core`, and caches
it. You only pay that cost once per engine version - later runs use the cached copy
without a network call.
## Supported platforms
**Windows x86_64**, **Linux x86_64 / arm64**, **macOS arm64 / x86_64**.
On macOS the app is ad-hoc signed, not notarized. If Gatekeeper complains the first
time it runs, clear the quarantine flag once:
```bash
xattr -dr com.apple.quarantine /path/to/cached/Firefox.app
```
**Windows x86_64**, **Linux x86_64 / arm64**. There is no macOS engine: its
build ended on 2026-08-26.
`invisible-playwright version` prints the cache location, and
`invisible-playwright fetch` prints the exact binary path as its last line.
@@ -66,7 +62,7 @@ the [CLI reference](cli-reference.md).
## Short answers to the questions that lead here
**Do I need to install Firefox myself?** No. `python -m invisible_playwright fetch`
**Do I need to install Firefox myself?** No. `uv run invisible-playwright fetch`
downloads the patched binary for you, verifies it, and caches it - there is nothing
to install separately.
@@ -83,9 +79,7 @@ Point `INVPW_BINARY_PATH` at a binary you already have to skip the download
entirely. [Configuration](configuration.md) lists the other environment variables,
including the ones for corporate networks and CI.
**Which platforms are supported?** Windows x86_64, Linux x86_64/arm64, and macOS
arm64/x86_64. macOS needs the quarantine flag cleared once if Gatekeeper complains
on first launch.
**Which platforms are supported?** Windows x86_64 and Linux x86_64/arm64.
**See also:** [Configuration](configuration.md) for proxy, timezone and environment
variables, [CLI reference](cli-reference.md) for what `fetch` and `version` do in
+5 -3
View File
@@ -25,11 +25,13 @@ The engine and the identity come from the Python package even though the tests a
JavaScript. Get them once:
```bash
pip install invisible-playwright
invisible-playwright fetch # downloads it if missing, prints the binary path as its last line
python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
uv add invisible-playwright
uv run invisible-playwright fetch # downloads it if missing, prints the binary path as its last line
uv run python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
```
Run them in a uv project; [the README's install steps](https://github.com/feder-cr/invisible_playwright#install) create one.
Regenerate `prefs.json` when you upgrade the package: the pref set moves with the
engine. Keep the seed written down next to it, because that number is the identity.
+5 -3
View File
@@ -27,11 +27,13 @@ The engine and the identity are produced by the Python package even though the
crawler is Node. Get them once, at install or deploy time:
```bash
pip install invisible-playwright
invisible-playwright fetch > .browser-path
python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
uv add invisible-playwright
uv run invisible-playwright fetch > .browser-path
uv run python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
```
Run them in a uv project; [the README's install steps](https://github.com/feder-cr/invisible_playwright#install) create one.
Yes, a Python dependency in a Node project. That is the real cost of this route,
and if it is unacceptable, the answer is a Chromium-based tool rather than a
workaround.
+1 -1
View File
@@ -20,7 +20,7 @@ check the signature before blaming the engine.
## What you need
```bash
pip install crawlee[playwright] invisible-playwright
uv add crawlee[playwright] invisible-playwright
```
The patched Firefox binary is downloaded on first launch and cached, so the first
+5 -3
View File
@@ -29,11 +29,13 @@ Verified 2026-07-27 by reading each binding's own launch options.
## Step one: get the two values
Run the commands below in a uv project; [the README's install steps](https://github.com/feder-cr/invisible_playwright#install) create one.
The binary has a CLI:
```bash
pip install invisible-playwright
invisible-playwright fetch # downloads and caches it once, prints the absolute path
uv add invisible-playwright
uv run invisible-playwright fetch # downloads and caches it once, prints the absolute path
```
The preferences do not, and that is a real gap instead of an omission from this
@@ -41,7 +43,7 @@ page: there is no `prefs` subcommand today, so you generate them with a one-line
and keep the JSON.
```bash
python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
uv run python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
```
Regenerate it when you upgrade the package, since the pref set moves with the engine.
+4 -2
View File
@@ -32,10 +32,12 @@ Written against `microsoft/playwright-mcp` as of 2026-07-27.
## The short version
```bash
pip install invisible-playwright
python -c "from invisible_playwright import ensure_binary; print(ensure_binary())"
uv add invisible-playwright
uv run python -c "from invisible_playwright import ensure_binary; print(ensure_binary())"
```
Run them in a uv project; [the README's install steps](https://github.com/feder-cr/invisible_playwright#install) create one.
The second command downloads the patched Firefox on first run, caches it, and prints
the path. Give that path to the MCP server:
+4 -4
View File
@@ -31,10 +31,10 @@ The engine and the identity come from the Python package, which suits Robot Fram
since it is Python underneath anyway.
```bash
pip install robotframework-browser invisible-playwright
rfbrowser init
invisible-playwright fetch # downloads if needed, prints the path as its last line
python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
uv add robotframework-browser invisible-playwright
uv run rfbrowser init
uv run invisible-playwright fetch # downloads if needed, prints the path as its last line
uv run python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
```
Regenerate `prefs.json` when you upgrade the package. Keep the seed written next to
+1 -1
View File
@@ -22,7 +22,7 @@ is the reference; this one explains which route to pick and what each one costs.
## Install
```bash
pip install "scrapy-playwright>=0.0.48" invisible-playwright
uv add "scrapy-playwright>=0.0.48" invisible-playwright
```
The patched Firefox is downloaded on first launch and cached. You do not need
+5 -3
View File
@@ -26,11 +26,13 @@ build's own defaults on every launch, which is a different product from
Get the two values first, the same way for all four:
```bash
pip install invisible-playwright
invisible-playwright fetch
python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
uv add invisible-playwright
uv run invisible-playwright fetch
uv run python -c "import json;from invisible_playwright import get_default_stealth_prefs;print(json.dumps(get_default_stealth_prefs(seed=1, humanize=True)))" > prefs.json
```
Run them in a uv project; [the README's install steps](https://github.com/feder-cr/invisible_playwright#install) create one.
## Cypress
Cypress launches Firefox through geckodriver and builds a `moz:firefoxOptions` with
@@ -132,7 +132,7 @@ Do not assume, read it. The launch is a two-line change from stock Playwright, a
every method after it is standard Playwright. Install it first:
```bash
pip install invisible-playwright
uv add invisible-playwright
```
Then ask an IP-echo endpoint, from inside the proxied browser, which address it saw,
+1 -1
View File
@@ -42,7 +42,7 @@ I/O-bound, so this rarely matters in practice, but it is not universally true.
**Distribution to non-technical end users.** A Python automation script needs
a Python environment, or a packaging step (PyInstaller and similar), to reach
someone who is not going to run `pip install`. If the deliverable is a
someone who is not going to run a package installer. If the deliverable is a
double-clickable app for someone else's machine, this is real friction that a
compiled or web-based alternative does not have.
+29 -1
View File
@@ -108,6 +108,7 @@ profile disagree with the browser, on about 12% of seeds.
| `screen.height` | int | `1440` |
| `screen.dpr` | float | `1.0`, `1.25`, `1.5`, `2.0` |
| `screen.color_depth` | int | `24` | `screen.colorDepth` and `screen.pixelDepth`. Declared rather than read off the panel: the engine only returned a fixed 24 when resistFingerprinting was on, which we do not turn on because it is itself a tell, so before this it reported the real display - 30 on a wide-gamut monitor, and a persona claiming an office laptop with a 30-bit panel is a contradiction a page can read. |
| `screen.refresh_hz` | int | `60`, `144` | The monitor's refresh rate, which is the cadence of `requestAnimationFrame`: a page reads it from the gap between two frame timestamps. Without it the engine follows the host's display, so one persona answered about 120 on one machine and 58 on another. Not sampled: 60 is what an office laptop or monitor runs at, and a 144 Hz persona is one pin away. |
### `hardware.*`
@@ -167,7 +168,8 @@ would be the signal. They are pinnable for A/B work, not for realism.
| Key | Type | Example | Notes |
|-----|------|---------|-------|
| `font.ui_family` | str | `"Segoe UI"` | Family behind `font: menu`, `font: caption`, and the `-moz-` widget fonts. |
| `font.ui_family` | str | `"Segoe UI"` | Family behind `font: menu` and `font: caption`. The form-control fonts take `font.dialog_family`. |
| `font.dialog_family` | str | `"MS Shell Dlg 2"` | The family of the form-control fonts, `-moz-button`, `-moz-field` and `-moz-list`, which is not the shell font: Windows Firefox builds them from the message font under the name "MS Shell Dlg 2", and a page reads it with one `getComputedStyle(input).fontFamily`. |
| `font.ui_size` | str | `"12"` | **A string, not an int.** Gecko reads this pref through `Preferences::GetFloat`, which parses the value from its text form; an int is not rejected, it is ignored, and the UI silently falls back to 16px. |
| `font.monospace_size` | int | `13` | Default monospace size. Firefox ships 13 on Windows and 12 in its Unix block, and the gap is directly readable as the width of the `monospace` generic at the default size. |
| `font.alpha_ladder` | tuple of int | `(0, 18, 35, ..., 255)` | The distinct alpha levels a Windows rasteriser leaves on an antialiased glyph edge, ascending, first `0` and last `255` so a fully transparent or fully opaque pixel never moves. Canvas readback snaps onto these. An empty tuple disables the snap, which is what you want when measuring what the unsnapped edge looks like. |
@@ -180,6 +182,32 @@ would be the signal. They are pinnable for A/B work, not for realism.
| `font.freetype_gamma` | int | `220` | The FreeType equivalent of `cleartype_gamma`, x100. Declared so the Linux build rasterises with Windows' curve instead of Skia's linear default. |
| `font.freetype_contrast` | int | `100` | The FreeType equivalent of `cleartype_contrast`, x100. |
### `desktop.*`
The Windows desktop settings a page can read, declared instead of asked of the
machine. Each one is a value whose engine default either reads the host or
differs between Windows and Linux, so without it the same persona answered
with the machine it ran on. The defaults are a Windows 11 desktop at its
defaults, and they are not sampled.
| Key | Type | Default | Notes |
|-----|------|---------|-------|
| `desktop.text_scale` | int | `100` | Windows' "Text size" slider, in percent. It multiplies the device pixel ratio, so `100` is the value that leaves `screen.dpr` the one number for it. |
| `desktop.overlay_scrollbars` | bool | `True` | Windows 11's "Automatically hide scroll bars": scrollbars draw over the content, so a scrolling box loses no width (`offsetWidth - clientWidth` is 0). Off, they take `desktop.scrollbar_size`. |
| `desktop.scrollbar_style` | int | `5` | How scrollbars are drawn: 5 Windows 11, 4 Windows 10, 2 GTK. |
| `desktop.scrollbar_size` | int | `17` | The width a scrollbar takes when it is not an overlay, at 96 dpi. |
| `desktop.drag_threshold` | int | `3` | How far the pointer moves before `dragstart`. |
| `desktop.scroll_to_click` | bool | `False` | A click in a scrollbar's track jumps there instead of paging. |
| `desktop.document_colors` | int | `0` | When the page's colours give way to the system's: `0`, the Windows default, only under a high-contrast theme. |
| `desktop.select_styling` | bool | `True` | A page may style a `<select>`'s popup, as on Windows. |
| `desktop.word_select_eats_space` | bool | `True` | A double click selects the word and the space after it, as on Windows; a page reads it with `getSelection()` after a real double click. |
| `desktop.srgb_output` | bool | `True` | Tagged images are converted to sRGB instead of the host monitor's colour profile, which a small canvas reads back. |
| `desktop.os_client_certs` | bool | `False` | Whether the operating system's personal certificates answer a server that asks for one. Off: the persona has none. |
| `desktop.theme_accent` | bool | `False` | Whether the page-visible `AccentColor` follows the desktop theme's accent; on Windows it does not. |
| `desktop.hour_cycle` | int | `0` | The clock format, `0` meaning the locale decides, as on Windows; otherwise the host's 12/24-hour setting changes every `toLocaleTimeString()`. |
| `desktop.select_on_focus` | bool | `True` | Tabbing into a pre-filled field selects all of it, as on Windows. |
| `desktop.palette` | str | *(the Windows palette)* | The system colours, light and dark, as `ui.<name>\|<light>\|<dark>` records, one per line, the dark part empty where the scheme does not move it. Every persona carries both schemes; `dark_theme` says which one it uses. |
### Top-level
| Key | Type | Example | Notes |
+3 -3
View File
@@ -23,8 +23,8 @@ is the fastest way to tell the three apart.
## Cause 1: the browsers were never downloaded
The library and the binaries are decoupled on purpose, so `pip install playwright` or
`npm install playwright` alone leaves you with a client and no browser to drive:
The library and the binaries are decoupled on purpose, so installing the `playwright`
package from PyPI or npm alone leaves you with a client and no browser to drive:
```bash
playwright install # every browser Playwright supports
@@ -144,7 +144,7 @@ changing anything, since the fix for each is different and none of them is guess
a specific cache path and did not find a runnable one there. The message names the exact
path it checked.
**Does `npm install playwright` or `pip install playwright` include the browsers?**
**Does installing the `playwright` package from npm or PyPI include the browsers?**
No. The package is the client library; `playwright install` is a separate, required step
that downloads the actual browser binaries.
+5 -3
View File
@@ -43,9 +43,11 @@ Most current Debian and Ubuntu base images are published as multi-architecture m
```dockerfile
FROM --platform=linux/arm64 debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip ca-certificates
RUN pip install invisible-playwright
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates
RUN uv venv --python ">=3.11" /opt/venv
ENV VIRTUAL_ENV=/opt/venv PATH="/opt/venv/bin:$PATH"
RUN uv pip install --no-cache invisible-playwright
```
The `--platform` flag pins the build explicitly rather than relying on the Docker daemon's default, which matters if you build on one machine and deploy to another. For a real GPU, font set, or screen presented to the browser instead of a bare container's defaults, see [How to run Playwright in Docker without getting detected](how-to-run-playwright-docker-undetected.md); it applies the same way on arm64, only the base image and engine differ by architecture.
+2 -1
View File
@@ -34,6 +34,7 @@ Debian and Ubuntu-based images, which most Playwright containers are, ship almos
```dockerfile
FROM python:3.11-slim
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
RUN apt-get update && apt-get install -y --no-install-recommends \
fonts-noto \
@@ -46,7 +47,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN uv pip install --system --no-cache -r requirements.txt
RUN python -m invisible_playwright fetch
+1 -1
View File
@@ -108,7 +108,7 @@ anecdotal. Fix the seed, capture, and assert two things at once: the screenshot
is a sane size and it is a real image, not a wall of noise.
```bash
pip install invisible-playwright
uv add invisible-playwright
```
```python
@@ -132,10 +132,11 @@ to add, because the engine downloads itself on first use:
```dockerfile
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
RUN apt-get update \
&& apt-get install -y --no-install-recommends xvfb \
&& rm -rf /var/lib/apt/lists/*
RUN pip install invisible-playwright
RUN uv pip install --system invisible-playwright
COPY scrape.py .
CMD ["python", "scrape.py"]
```
@@ -55,8 +55,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v6
- name: Install
run: pip install invisible-playwright
run: uv pip install --system invisible-playwright
- name: Run
run: python scrape.py
```
@@ -199,7 +199,8 @@ describe:
```dockerfile
FROM python:3.12-slim
RUN pip install invisible-playwright
COPY --from=ghcr.io/astral-sh/uv:0.12.10 /uv /uvx /bin/
RUN uv pip install --system invisible-playwright
ENV INVISIBLE_PLAYWRIGHT_CACHE_DIR=/engines
VOLUME /engines
COPY scrape_job.py /srv/scrape_job.py
@@ -43,7 +43,7 @@ That directness is the whole reason the fixture pair works cleanly:
Install what you need first:
```bash
pip install invisible-playwright pytest pytest-asyncio
uv add invisible-playwright pytest pytest-asyncio
```
And turn on pytest-asyncio's auto mode so you do not decorate every test by hand. In
+1 -1
View File
@@ -146,7 +146,7 @@ with InvisiblePlaywright(seed=42, proxy=proxy) as browser:
```
```bash
pip install invisible-playwright
uv add invisible-playwright
```
If your project is committed to Chrome and to an async Python API of its own, and
+1 -1
View File
@@ -105,7 +105,7 @@ Switching from plain Playwright is the same two-line change it always is, and th
object is a real Playwright `Browser` with every method intact:
```bash
pip install invisible-playwright
uv add invisible-playwright
```
```python
+1 -1
View File
@@ -191,7 +191,7 @@ authentication](playwright-socks5-proxy-authentication.md).
A minimal install to run the snippet:
```bash
pip install invisible-playwright
uv add invisible-playwright
```
## Conclusion
+2 -2
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "invisible_playwright"
version = "0.37.0"
version = "0.38.0"
description = "Playwright wrapper for a patched Firefox with deterministic stealth profile."
readme = "README.md"
requires-python = ">=3.11"
@@ -69,7 +69,7 @@ dependencies = [
# metadata; nothing in src/ hardcodes a second copy (tests/test_core_pin.py
# fails if one appears). What stays invisible to install-time machinery is the
# --no-deps / lockfile residue, and _pin.py is the only layer that sees it.
"invisible_core==49.44.0",
"invisible_core==49.46.0",
# ⛔ playwright is NO LONGER a dependency: since the full fork, the Python
# client lives in src/invisible_playwright/_pw/ and the Node driver in
# src/invisible_playwright/_driver/. Reintroducing it would not visibly
+7 -1
View File
@@ -98,11 +98,17 @@ def assert_playwright_range() -> None:
if t(seal.playwright_min) <= t(have) <= t(seal.playwright_max):
return
# Spelled by the tool that installed this package (`invisible_core.installer`):
# a written `pip install` is a command the venv the README makes does not have.
from invisible_core.installer import install
from invisible_core.pin import format_command
fix = format_command(install("invisible-playwright", f"playwright=={seal.playwright_max}"))
msg = (f"playwright {have} is outside the range this engine was tested with "
f"({seal.playwright_min} .. {seal.playwright_max}, from the seal for {seal.tag}).\n"
f"The Juggler protocol schema is closed-world: an untested client can kill every "
f"session at context creation.\n"
f'Run: pip install "playwright=={seal.playwright_max}" '
f"Run: {fix} "
f"(or set INVISIBLE_PLAYWRIGHT_SKEW=allow to proceed anyway)")
if os.environ.get("INVISIBLE_PLAYWRIGHT_SKEW") == "allow":
warnings.warn(msg, RuntimeWarning, stacklevel=2)
+35 -9
View File
@@ -19,11 +19,12 @@ is the whole floor, and its except branches classify the failure:
installed at all, or it is older than this check and ships no
invisible_core.pin (or no invisible_core.pin.enforce_core_pin). Those
cannot be told apart from here and do not need to be: one remedy fixes all
of them, `pip install --force-reinstall invisible-playwright`, which makes
pip resolve the core version from our own Requires-Dist. No version literal
in the message, so nothing here can drift out of step with pyproject.
of them, a force-reinstall of invisible-playwright (`reinstall_command`, spelled
by the tool that installed it), which makes the installer resolve the core
version from our own Requires-Dist. No version literal in the message, so
nothing here can drift out of step with pyproject.
* ImportError naming any other module - the core is installed and one of ITS
dependencies is missing. That is what `pip install --no-deps` leaves behind,
dependencies is missing. That is what an install with `--no-deps` leaves behind,
and reporting it as "invisible-core is not installed" sends the user to the
wrong package.
* anything else - the core is on disk and its import raised something that is
@@ -51,6 +52,31 @@ import sys as _sys
DIST_NAME = "invisible-playwright"
def reinstall_command() -> str:
"""The command that reinstalls this distribution, as the tool that
installed it spells it: the one remedy this floor hands over.
`invisible_core.installer` is where every other install command comes from,
and it cannot be asked here: the floor speaks exactly when the core does not
import. So this reads the same INSTALLER record with the standard library
and takes the same two branches, for this one command. Until 2026-10-17 it was
`pip install --force-reinstall` for everybody, and the venv the README makes
(`uv init` + `uv add`) has no pip in it.
"""
from importlib.metadata import PackageNotFoundError, distribution
try:
record = distribution(DIST_NAME).read_text("INSTALLER")
except PackageNotFoundError:
record = None
if (record or "").strip().lower() == "uv":
cmd = ["uv", "pip", "install", "--python", _sys.executable,
"--force-reinstall", DIST_NAME]
else:
cmd = [_sys.executable, "-m", "pip", "install", "--force-reinstall", DIST_NAME]
return " ".join(f'"{t}"' if " " in t else t for t in cmd)
# Captured BEFORE the core is imported, and it is the whole soundness argument
# for the in-process repair: if nothing has imported invisible_core by the time
# this package's __init__ starts, then nobody is holding an object from the
@@ -105,16 +131,16 @@ except ImportError as _e:
f"invisible-core is installed but cannot be imported: no module named "
f"{_missing!r}.\n"
f"That is one of its own dependencies, so it was installed without "
f"dependency resolution (pip install --no-deps, or a lockfile that "
f"lists the packages separately).\n"
f"Run: pip install --force-reinstall {DIST_NAME}"
f"dependency resolution (an install with --no-deps, or a lockfile "
f"that lists the packages separately).\n"
f"Run: {reinstall_command()}"
) from _e
raise ImportError(
"invisible-core is missing, or too old for this invisible-playwright: it "
"does not carry the release-pin check (invisible_core.pin), so the engine "
"it downloads cannot be matched against the configuration this package "
"ships.\n"
f"Run: pip install --force-reinstall {DIST_NAME}"
f"Run: {reinstall_command()}"
) from _e
except Exception as _e:
raise ImportError(
@@ -124,7 +150,7 @@ except Exception as _e:
f"unreadable invisible_core/seal.json is the usual cause, and it is read "
f"while invisible_core is still importing, so nothing inside the core can "
f"report it.\n"
f"Run: pip install --force-reinstall {DIST_NAME}"
f"Run: {reinstall_command()}"
) from _e
+2 -2
View File
@@ -92,7 +92,7 @@ try:
tz_env,
)
except ImportError as _exc: # pragma: no cover - exercised by the old-core probe
from ._pin import declared_core_pin as _declared_core_pin
from ._pin import declared_core_pin as _declared_core_pin, reinstall_command
try:
_want = _declared_core_pin() or "a newer version"
@@ -101,7 +101,7 @@ except ImportError as _exc: # pragma: no cover - exercised by the old-core prob
raise ImportError(
f"invisible-playwright needs invisible-core {_want}: the installed one "
f"does not provide the timezone conversion this version imports "
f"({_exc}). Upgrade with `pip install -U invisible-playwright`, which "
f"({_exc}). Reinstall it with `{reinstall_command()}`, which "
f"pulls the core it was built against."
) from _exc
+2 -2
View File
@@ -74,8 +74,8 @@ def test_shim_output_matches_core_output():
# `forced_gpu_class` is still imported above, because the import SHAPE is
# what this file exists to protect; it is a query now rather than a knob.
assert fgc_pw(42) == ic.forced_gpu_class(42)
a = tp_pw(gp_pw(42))
b = ic.translate_profile_to_prefs(ic.generate_profile(42))
a = tp_pw(gp_pw(42), timezone="America/New_York")
b = ic.translate_profile_to_prefs(ic.generate_profile(42), timezone="America/New_York")
assert a == b
+2 -2
View File
@@ -49,7 +49,7 @@ def test_ci_font_gate_generics_match_the_core():
from invisible_core._fpforge import generate_profile
from invisible_core.prefs import translate_profile_to_prefs
prefs = translate_profile_to_prefs(generate_profile(970411))
prefs = translate_profile_to_prefs(generate_profile(970411), timezone="America/New_York")
from_core = prefs["zoom.stealth.fonts.generics"]
from_gate = _generics_decl_from_gate()
@@ -74,7 +74,7 @@ def test_the_generics_declaration_does_not_depend_on_the_seed():
from invisible_core.prefs import translate_profile_to_prefs
values = {
translate_profile_to_prefs(generate_profile(s))["zoom.stealth.fonts.generics"]
translate_profile_to_prefs(generate_profile(s), timezone="America/New_York")["zoom.stealth.fonts.generics"]
for s in (1, 42, 970411, 20260811, 999999)
}
assert len(values) == 1, (
+4 -1
View File
@@ -43,7 +43,10 @@ SRC = ROOT / "src" / "invisible_playwright"
PYPROJECT = ROOT / "pyproject.toml"
SHIM = (SRC / "_pin.py").read_text(encoding="utf-8")
REMEDY = "pip install --force-reinstall invisible-playwright"
# The floor's one remedy, as the tool that installed this package spells it
# (`_pin.reinstall_command`). The children below run this interpreter, so they
# read the same INSTALLER record and print the same line.
REMEDY = _pin.reinstall_command()
def child_env(**overrides) -> dict:
+3 -3
View File
@@ -74,7 +74,7 @@ def test_baseline_keeps_fission_autostart_off():
def test_translated_profile_propagates_isolation_strategy():
"""The fix must survive translate_profile_to_prefs, not just live in _BASELINE."""
p = generate_profile(seed=42)
prefs = translate_profile_to_prefs(p)
prefs = translate_profile_to_prefs(p, timezone="America/New_York")
assert prefs["fission.webContentIsolationStrategy"] == 0
@@ -84,11 +84,11 @@ def test_extra_prefs_override_can_break_isolation_only_explicitly():
The wrapper does not silently flip it back on.
"""
p = generate_profile(seed=42)
prefs_default = translate_profile_to_prefs(p)
prefs_default = translate_profile_to_prefs(p, timezone="America/New_York")
assert prefs_default["fission.webContentIsolationStrategy"] == 0
prefs_ab = translate_profile_to_prefs(
p, extra_prefs={"fission.webContentIsolationStrategy": 1}
p, timezone="America/New_York", extra_prefs={"fission.webContentIsolationStrategy": 1}
)
assert prefs_ab["fission.webContentIsolationStrategy"] == 1
+15 -15
View File
@@ -192,7 +192,7 @@ def test_python_engine_turns_the_browser_side_expansion_off(stub_motion):
path, every waypoint we send would be expanded into a whole path of its
own: a hundred-fold event storm, and a shape neither generator intended.
"""
ip = InvisiblePlaywright(seed=42, humanize=True)
ip = InvisiblePlaywright(timezone="America/New_York", seed=42, humanize=True)
assert ip._cursor_engine == _cursor.ENGINE_PYTHON
prefs = ip._build_prefs()
assert prefs["stealthfox.humanize"] is False
@@ -201,7 +201,7 @@ def test_python_engine_turns_the_browser_side_expansion_off(stub_motion):
@pytest.mark.unit
def test_humanize_false_disables_everything(stub_motion):
ip = InvisiblePlaywright(seed=42, humanize=False)
ip = InvisiblePlaywright(timezone="America/New_York", seed=42, humanize=False)
assert ip._cursor_engine == _cursor.ENGINE_OFF
prefs = ip._build_prefs()
assert prefs["stealthfox.humanize"] is False
@@ -210,7 +210,7 @@ def test_humanize_false_disables_everything(stub_motion):
@pytest.mark.unit
def test_humanize_float_still_means_a_cap_in_seconds(stub_motion):
ip = InvisiblePlaywright(seed=42, humanize=2.5)
ip = InvisiblePlaywright(timezone="America/New_York", seed=42, humanize=2.5)
assert ip._cursor_engine == _cursor.ENGINE_PYTHON
# Was `ip._humanize_max_seconds()`, a wrapper with no caller in src/. The
# live arming path reads the cap straight off this function.
@@ -222,7 +222,7 @@ def test_escape_hatch_restores_the_previous_behaviour(stub_motion, monkeypatch):
"""The way back: INVPW_CURSOR_ENGINE=binary is byte-identical to the old
wiring - pref on, cap forwarded, and nothing armed on our side."""
monkeypatch.setenv(_cursor.ENGINE_ENV, "binary")
ip = InvisiblePlaywright(seed=42, humanize=3.0)
ip = InvisiblePlaywright(timezone="America/New_York", seed=42, humanize=3.0)
assert ip._cursor_engine == _cursor.ENGINE_BINARY
prefs = ip._build_prefs()
assert prefs["stealthfox.humanize"] is True
@@ -232,7 +232,7 @@ def test_escape_hatch_restores_the_previous_behaviour(stub_motion, monkeypatch):
@pytest.mark.unit
def test_escape_hatch_off_disables_motion_without_touching_the_constructor(stub_motion, monkeypatch):
monkeypatch.setenv(_cursor.ENGINE_ENV, "off")
ip = InvisiblePlaywright(seed=42, humanize=True)
ip = InvisiblePlaywright(timezone="America/New_York", seed=42, humanize=True)
assert ip._cursor_engine == _cursor.ENGINE_OFF
assert ip._build_prefs()["stealthfox.humanize"] is False
@@ -246,9 +246,9 @@ def test_the_show_cursor_kwarg_reaches_the_prefs(stub_motion):
attribute we stored: `_show_cursor` being True proves only that `__init__`
ran.
"""
on = InvisiblePlaywright(seed=42, show_cursor=True)._build_prefs()
off = InvisiblePlaywright(seed=42, show_cursor=False)._build_prefs()
silent = InvisiblePlaywright(seed=42)._build_prefs()
on = InvisiblePlaywright(timezone="America/New_York", seed=42, show_cursor=True)._build_prefs()
off = InvisiblePlaywright(timezone="America/New_York", seed=42, show_cursor=False)._build_prefs()
silent = InvisiblePlaywright(timezone="America/New_York", seed=42)._build_prefs()
assert on["stealthfox.showcursor"] is True
assert off["stealthfox.showcursor"] is False
# ⛔ SAYING NOTHING IS NOT SAYING FALSE. The overlay ships ON since
@@ -262,7 +262,7 @@ def test_the_show_cursor_kwarg_reaches_the_prefs(stub_motion):
def test_the_dot_and_the_motion_are_two_switches(stub_motion):
"""Watching a TELEPORTING cursor is a legitimate thing to want, and it is
the combination a derivation would quietly forbid."""
prefs = InvisiblePlaywright(seed=42, humanize=False,
prefs = InvisiblePlaywright(timezone="America/New_York", seed=42, humanize=False,
show_cursor=True)._build_prefs()
assert prefs["stealthfox.humanize"] is False
assert prefs["stealthfox.showcursor"] is True
@@ -273,7 +273,7 @@ def test_missing_generator_falls_back_to_the_browser(no_motion):
"""A session must always be able to move. With no generator installed we
hand the job back to the browser rather than shipping a teleporting
cursor."""
ip = InvisiblePlaywright(seed=42, humanize=True)
ip = InvisiblePlaywright(timezone="America/New_York", seed=42, humanize=True)
assert ip._cursor_engine == _cursor.ENGINE_BINARY
assert ip._build_prefs()["stealthfox.humanize"] is True
@@ -283,8 +283,8 @@ def test_sync_and_async_agree_on_the_prefs(stub_motion):
"""Both launchers must derive the prefs from the same helper - a divergence
here is a silent double expansion in exactly one of the two APIs."""
for humanize in (True, False, 2.0):
sync = InvisiblePlaywright(seed=42, humanize=humanize)
asy = AsyncInvisiblePlaywright(seed=42, humanize=humanize)
sync = InvisiblePlaywright(timezone="America/New_York", seed=42, humanize=humanize)
asy = AsyncInvisiblePlaywright(timezone="America/New_York", seed=42, humanize=humanize)
assert sync._cursor_engine == asy._cursor_engine
assert _humanize_subset(sync) == _humanize_subset(asy)
@@ -350,7 +350,7 @@ def test_the_launcher_hands_over_its_own_seed(stub_motion, monkeypatch):
return True
monkeypatch.setattr("invisible_playwright._session._enable_cursor_engine", spy)
ip = InvisiblePlaywright(seed=777, humanize=2.0)
ip = InvisiblePlaywright(timezone="America/New_York", seed=777, humanize=2.0)
ip._arm_cursor_engine(_FakeBrowser())
assert seen == {"seed": 777, "max_seconds": 2.0}
assert ip.seed == 777
@@ -365,7 +365,7 @@ def test_binary_engine_arms_nothing(stub_motion, monkeypatch):
lambda *a, **k: called.append(a),
)
monkeypatch.setenv(_cursor.ENGINE_ENV, "binary")
InvisiblePlaywright(seed=1, humanize=True)._arm_cursor_engine(_FakeBrowser())
InvisiblePlaywright(timezone="America/New_York", seed=1, humanize=True)._arm_cursor_engine(_FakeBrowser())
assert called == []
@@ -1295,7 +1295,7 @@ def test_the_core_we_resolve_against_decides_the_cursor_default():
from invisible_core.prefs import DEFAULT_SHOW_CURSOR
assert isinstance(DEFAULT_SHOW_CURSOR, bool)
ip = InvisiblePlaywright(seed=42)
ip = InvisiblePlaywright(timezone="America/New_York", seed=42)
assert ip._build_prefs()["stealthfox.showcursor"] is DEFAULT_SHOW_CURSOR, (
"the wrapper's silent default disagrees with the core's declaration; "
"one of the two has grown a second opinion")
+3 -3
View File
@@ -166,7 +166,7 @@ def test_e9_linux_build_prefs_omits_windows_sandbox_key(monkeypatch):
from invisible_playwright import _session as _l
monkeypatch.setattr(_l, "make_virtual_display", lambda: _FakeDisplay())
ip = InvisiblePlaywright(seed=42, headless=True)
ip = InvisiblePlaywright(timezone="America/New_York", seed=42, headless=True)
ip._resolve_headless()
assert ip._virtual_display is not None, "the stub display was not wired up"
prefs = ip._build_prefs()
@@ -202,7 +202,7 @@ def test_e9b_windows_build_prefs_follows_the_desktop_that_was_created(monkeypatc
from invisible_playwright import _session as _l
monkeypatch.setattr(_l, "make_virtual_display", lambda: _FakeDesktop())
hidden = InvisiblePlaywright(seed=42, headless=True)
hidden = InvisiblePlaywright(timezone="America/New_York", seed=42, headless=True)
hidden._resolve_headless()
assert hidden._virtual_display is not None, "the desktop was not wired up"
prefs = hidden._build_prefs()
@@ -210,7 +210,7 @@ def test_e9b_windows_build_prefs_follows_the_desktop_that_was_created(monkeypatc
assert prefs["security.sandbox.content.level"] == 4
assert "zoom.stealth.cloak_windows" not in prefs
headed = InvisiblePlaywright(seed=42, headless=False)
headed = InvisiblePlaywright(timezone="America/New_York", seed=42, headless=False)
headed._resolve_headless()
assert headed._virtual_display is None
prefs = headed._build_prefs()
+29 -38
View File
@@ -17,10 +17,8 @@ import pytest
from invisible_core._fpforge import generate_profile
from invisible_core._proxy import configure_proxy
from invisible_core.prefs import (
_WIN_LIGHT_COLORS,
translate_profile_to_prefs,
)
from invisible_core._fpforge.palette import _WIN_DARK_COLORS, _WIN_LIGHT_COLORS
from invisible_core.prefs import translate_profile_to_prefs
# Keys every Profile-derived prefs dict MUST carry.
@@ -56,7 +54,6 @@ _REQUIRED_PREFS_KEYS = (
"media.encoder.webm.enabled",
"ui.systemUsesDarkTheme",
"intl.accept_languages",
"general.useragent.locale",
"intl.locale.requested",
"zoom.stealth.fpp.hw_seed",
"zoom.stealth.webrtc.host_ip",
@@ -82,7 +79,7 @@ def test_generate_profile_then_translate_has_all_required_keys():
returned dict contains every key downstream code (Playwright, the C++
patches) needs to find."""
profile = generate_profile(seed=42)
prefs = translate_profile_to_prefs(profile)
prefs = translate_profile_to_prefs(profile, timezone="America/New_York")
missing = [k for k in _REQUIRED_PREFS_KEYS if k not in prefs]
assert not missing, f"prefs dict missing required keys: {missing}"
@@ -99,7 +96,7 @@ def test_socks5_proxy_mutates_prefs_then_pipeline_still_valid():
prefs dict; the result is still a valid prefs dict (all required keys
intact) and the proxy return is ``None`` so Playwright sees no proxy."""
profile = generate_profile(seed=42)
prefs = translate_profile_to_prefs(profile)
prefs = translate_profile_to_prefs(profile, timezone="America/New_York")
before = dict(prefs)
pw_proxy = configure_proxy(
@@ -147,7 +144,7 @@ def test_pin_screen_width_propagates_through_pipeline():
"""IT3 - a pinned ``screen.width`` shows up in the final prefs dict
under ``zoom.stealth.screen.width``."""
profile = generate_profile(seed=42, pin={"screen.width": 2560})
prefs = translate_profile_to_prefs(profile)
prefs = translate_profile_to_prefs(profile, timezone="America/New_York")
assert profile.screen.width == 2560
assert prefs["zoom.stealth.screen.width"] == 2560
@@ -164,7 +161,7 @@ def test_multiple_pins_all_visible_in_prefs():
"audio.sample_rate": 48000,
}
profile = generate_profile(seed=42, pin=pin)
prefs = translate_profile_to_prefs(profile)
prefs = translate_profile_to_prefs(profile, timezone="America/New_York")
assert prefs["zoom.stealth.screen.width"] == 3840
assert prefs["zoom.stealth.screen.height"] == 2160
@@ -181,8 +178,8 @@ def test_multiple_pins_all_visible_in_prefs():
def test_pipeline_deterministic_for_same_seed():
"""IT4 - running the full pipeline twice with the same seed produces
identical prefs dicts."""
a = translate_profile_to_prefs(generate_profile(seed=1234))
b = translate_profile_to_prefs(generate_profile(seed=1234))
a = translate_profile_to_prefs(generate_profile(seed=1234), timezone="America/New_York")
b = translate_profile_to_prefs(generate_profile(seed=1234), timezone="America/New_York")
assert a == b
@@ -191,8 +188,8 @@ def test_pipeline_varies_across_seeds():
"""IT5 - different seeds produce different prefs dicts. Compare the
full dict, not just a sampled field, to catch regressions where a
single hot field accidentally becomes seed-invariant."""
a = translate_profile_to_prefs(generate_profile(seed=1))
b = translate_profile_to_prefs(generate_profile(seed=2))
a = translate_profile_to_prefs(generate_profile(seed=1), timezone="America/New_York")
b = translate_profile_to_prefs(generate_profile(seed=2), timezone="America/New_York")
assert a != b
@@ -207,7 +204,7 @@ def test_http_proxy_returned_unchanged_no_socks_mutations():
SOCKS prefs are never written. Verifies the two proxy paths don't
cross-pollute the prefs dict."""
profile = generate_profile(seed=42)
prefs = translate_profile_to_prefs(profile)
prefs = translate_profile_to_prefs(profile, timezone="America/New_York")
proxy_in = {"server": "http://proxy.example.com:8080", "username": "bob"}
pw_proxy = configure_proxy(proxy_in, prefs)
@@ -232,7 +229,7 @@ def test_fonts_are_not_configured_via_prefs():
the config pipeline must emit NO font prefs. Locks the 2026-07-06
self-contained refactor (fonts moved entirely into the binary)."""
profile = generate_profile(seed=42)
prefs = translate_profile_to_prefs(profile)
prefs = translate_profile_to_prefs(profile, timezone="America/New_York")
assert "zoom.stealth.font.fontlist" not in prefs
assert "zoom.stealth.font.system_ui" not in prefs
@@ -246,26 +243,21 @@ def test_fonts_are_not_configured_via_prefs():
@pytest.mark.integration
def test_dark_theme_pipeline_omits_light_palette():
"""IT8.a - dark_theme=True profile → no light-palette colors in prefs."""
profile = generate_profile(seed=42, pin={"dark_theme": True})
prefs = translate_profile_to_prefs(profile)
@pytest.mark.parametrize("dark", [True, False])
def test_every_persona_carries_the_palette_of_both_schemes(dark):
"""IT8 - core 49.46.0: the palette goes to every persona, light and dark,
in `ui.<name>` and `ui.<name>.dark`. A page asks the engine for a colour in
either scheme (a `color-scheme: dark` box asks for the dark one); until
49.46.0 a dark persona got no palette at all and answered the host's
colours. Only `ui.systemUsesDarkTheme` says which scheme the persona uses."""
profile = generate_profile(seed=42, pin={"dark_theme": dark})
prefs = translate_profile_to_prefs(profile, timezone="America/New_York")
assert prefs["ui.systemUsesDarkTheme"] == 1
for key in _WIN_LIGHT_COLORS:
assert key not in prefs, f"dark theme leaked light color: {key}"
@pytest.mark.integration
def test_light_theme_pipeline_includes_light_palette():
"""IT8.b - dark_theme=False profile → full Win10 light palette is
overlaid onto the prefs dict."""
profile = generate_profile(seed=42, pin={"dark_theme": False})
prefs = translate_profile_to_prefs(profile)
assert prefs["ui.systemUsesDarkTheme"] == 0
assert prefs["ui.systemUsesDarkTheme"] == int(dark)
for key, value in _WIN_LIGHT_COLORS.items():
assert prefs[key] == value
assert prefs[key] == value, key
for key, value in _WIN_DARK_COLORS.items():
assert prefs[key] == value, key
# ──────────────────────────────────────────────────────────────────────
@@ -284,7 +276,7 @@ def test_many_seeds_all_produce_valid_prefs():
for seed in seeds:
profile = generate_profile(seed=seed)
prefs = translate_profile_to_prefs(profile)
prefs = translate_profile_to_prefs(profile, timezone="America/New_York")
missing = [k for k in _REQUIRED_PREFS_KEYS if k not in prefs]
assert not missing, f"seed={seed} missing keys: {missing}"
@@ -304,7 +296,7 @@ def test_windows_virtual_display_with_socks_proxy(monkeypatch):
land their keys in the prefs dict and don't clobber each other."""
monkeypatch.setattr(sys, "platform", "win32")
profile = generate_profile(seed=42)
prefs = translate_profile_to_prefs(profile, virtual_display=True)
prefs = translate_profile_to_prefs(profile, virtual_display=True, timezone="America/New_York")
pw_proxy = configure_proxy(
{"server": "socks5://127.0.0.1:1080"}, prefs
)
@@ -335,7 +327,7 @@ def test_linux_xvfb_workarounds_with_socks_proxy(monkeypatch):
on Linux must NOT set ``security.sandbox.gpu.level`` (covered by VD3)."""
monkeypatch.setattr(sys, "platform", "linux")
profile = generate_profile(seed=42)
prefs = translate_profile_to_prefs(profile, virtual_display=True)
prefs = translate_profile_to_prefs(profile, virtual_display=True, timezone="America/New_York")
pw_proxy = configure_proxy(
{"server": "socks5://127.0.0.1:1080"}, prefs
)
@@ -343,7 +335,6 @@ def test_linux_xvfb_workarounds_with_socks_proxy(monkeypatch):
assert pw_proxy is not None # a single path, here too
# Xvfb workarounds present.
assert prefs["gfx.webrender.all"] is False
assert prefs["gfx.webrender.force-disabled"] is True
assert prefs["webgl.force-enabled"] is True
# Windows-only sandbox key absent on Linux even with virtual_display=True.
assert "security.sandbox.gpu.level" not in prefs
@@ -385,7 +376,7 @@ def test_msaa_reaches_the_pipeline_identically_on_both_platforms(monkeypatch):
seen = {}
for platform in ("linux", "win32"):
monkeypatch.setattr(sys, "platform", platform)
prefs = translate_profile_to_prefs(generate_profile(seed=42))
prefs = translate_profile_to_prefs(generate_profile(seed=42), timezone="America/New_York")
seen[platform] = (prefs["webgl.msaa-samples"], prefs["webgl.msaa-force"])
assert seen["linux"] == seen["win32"] == (4, True), seen
+8 -2
View File
@@ -56,7 +56,11 @@ def test_an_older_core_names_the_version_it_needs(tmp_path):
root = _core_without(("tz_env", "IANA_TO_POSIX_TZ"), tmp_path / "old")
code = ("import invisible_playwright\n"
"print('IMPORTED')\n")
env = dict(os.environ, PYTHONPATH=str(root), INVISIBLE_CORE_AUTOFIX="off")
# The old core first, then THIS checkout's sources: with the core copy alone
# the child imports whichever wrapper is installed, which from a worktree is
# somebody else's tree, and the assertions read its messages, not these.
env = dict(os.environ, INVISIBLE_CORE_AUTOFIX="off",
PYTHONPATH=os.pathsep.join([str(root), str(_REPO / "src")]))
proc = subprocess.run([sys.executable, "-c", code], capture_output=True,
text=True, env=env, cwd=str(_REPO), timeout=180)
@@ -73,7 +77,9 @@ def test_an_older_core_names_the_version_it_needs(tmp_path):
assert final.index("needs invisible-core") < final.index("cannot import name"), (
"the symbol error comes before the version requirement, so the first "
"thing the reader sees is still the thing they cannot act on")
assert "pip install" in final, (
from invisible_playwright._pin import reinstall_command
assert reinstall_command() in final, (
"a failure at import time with no remedy is a support ticket")
+2 -2
View File
@@ -7,7 +7,7 @@ from invisible_core.prefs import translate_profile_to_prefs
def test_pin_screen_width_propagates_to_prefs():
p = generate_profile(seed=42, pin={"screen.width": 2560, "screen.height": 1440})
prefs = translate_profile_to_prefs(p)
prefs = translate_profile_to_prefs(p, timezone="America/New_York")
assert prefs["zoom.stealth.screen.width"] == 2560
assert prefs["zoom.stealth.screen.height"] == 1440
@@ -27,7 +27,7 @@ def test_pin_gpu_renderer_reaches_the_browser():
target = _gpu_pool()[-1]
p = generate_profile(seed=42, pin={"gpu.renderer": target["renderer"]})
assert p.gpu.renderer == target["renderer"]
prefs = translate_profile_to_prefs(p)
prefs = translate_profile_to_prefs(p, timezone="America/New_York")
assert prefs["zoom.stealth.webgl.renderer"] == target["renderer"]
assert prefs["zoom.stealth.webgl.vendor"] == target["vendor"]
+102 -36
View File
@@ -1,8 +1,10 @@
"""The install path a stranger takes, driven end to end.
A fresh venv, `pip install invisible-playwright` FROM THE INDEX, the engine
downloaded from the live GitHub release, and a real browser launched against a
real URL. Slow and network-bound, so marked `e2e` and excluded by default:
The README's install block for this system, run as written: uv from its own
installer, a project `uv init` made, `uv add invisible-playwright` FROM THE
INDEX, the engine downloaded from the live GitHub release, and then a real
browser launched against a real URL. Slow and network-bound, so marked `e2e`
and excluded by default:
pytest tests/test_release_e2e.py -m e2e -o addopts="" -v
@@ -32,13 +34,12 @@ something was already cached.
from __future__ import annotations
import os
import re
import shutil
import subprocess
import tempfile
from pathlib import Path
import sys
import pytest
# The variables that must NOT cross into a venv this file builds.
@@ -126,19 +127,65 @@ def _venv_python(venv_dir):
return Path(venv_dir) / bindir / name
def _make_venv(target, *, upgrade_pip: bool = True):
target = Path(target)
_run([sys.executable, "-m", "venv", target], timeout=300)
py = _venv_python(target)
assert py.exists(), "no venv python at {}".format(py)
if upgrade_pip:
_run([py, "-m", "pip", "install", "--upgrade", "pip", "--quiet"], timeout=300)
return py
# ── the README's install block, LOCAL ON PURPOSE for the reason above ────────
# The way in is uv (the owner, 2026-09-06; "uv everywhere", 2026-10-17), and the
# README carries it as one complete block per system. This file RUNS that block,
# read from the README, so the install it tests is the one a person copies and
# cannot drift from it: until 2026-10-17 it ran `pip install` while the README
# had been told to say uv.
README = Path(__file__).resolve().parents[1] / "README.md"
DIST = "invisible-playwright"
_INSTALLER = {"nt": "astral.sh/uv/install.ps1", "posix": "astral.sh/uv/install.sh"}
def readme_install_block() -> list:
"""The lines of the README's install block for this system: the code block
that runs uv's own installer for it."""
marker = _INSTALLER[os.name]
text = README.read_text(encoding="utf-8")
for body in re.findall(r"```[^\n]*\n(.*?)```", text, re.S):
if marker in body:
return [line for line in body.splitlines() if line.strip()]
raise AssertionError(f"README.md has no install block for this system: no "
f"code block runs {marker}")
def _home_bin(home: Path) -> Path:
return home / ".local" / "bin"
def run_readme_block(lines, *, cwd: Path, home: Path, env: dict):
"""Run the block the way its reader does - PowerShell on Windows, bash on
Linux - stopping at the first line that fails.
`home` stands in for the reader's home, so uv's installer lands in a
directory this run owns and the block's own PATH line finds it there; on
Windows `UV_NO_MODIFY_PATH` keeps it out of the registry. The lines are the
README's, unchanged: what is set here is the environment around them."""
env = dict(env)
env["UV_INSTALL_DIR"] = str(_home_bin(home))
# A cached index answer would hide a forgotten publish, which is what
# `--no-cache-dir` did for the pip version of this file.
env["UV_NO_CACHE"] = "1"
if os.name == "nt":
env["USERPROFILE"] = str(home)
env["UV_NO_MODIFY_PATH"] = "1"
# A native command's failure does not stop a PowerShell script, so each
# line is followed by the check a reader's eyes would make.
script = cwd / "install.ps1"
script.write_text("".join(f"{line}\nif ($LASTEXITCODE) {{ exit $LASTEXITCODE }}\n"
for line in lines), encoding="utf-8")
cmd = ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", script]
else:
env["HOME"] = str(home)
script = cwd / "install.sh"
script.write_text("set -eo pipefail\n" + "\n".join(lines) + "\n", encoding="utf-8")
cmd = ["bash", script]
return _run(cmd, cwd=cwd, env=env, timeout=1800)
run_checked = _run
venv_python = _venv_python
make_venv = _make_venv
# NOT imported at module level. This file is collected in an environment that
@@ -185,7 +232,6 @@ REV = os.environ.get("INVPW_E2E_REV", "main")
# comment, which is exactly the behaviour it is for.)
_run = run_checked
_venv_python = venv_python
_make_venv = make_venv
@pytest.fixture(scope="module")
@@ -198,14 +244,29 @@ def workspace() -> Path:
@pytest.fixture(scope="module")
def clean_venv(workspace: Path) -> Path:
"""A fresh venv, pip upgraded. Returns its python executable path.
def clean_venv(workspace: Path, isolated_cache_env: dict) -> Path:
"""The venv the README's install block makes, from the index. Returns its
python executable path.
Inside `workspace` rather than a temp dir of its own: the engine tarball
and a private cache dir live there too, and re-downloading 110 MB per test
is what the shared workspace exists to avoid.
The block runs once for the module, in `workspace`, with the private cache
the tests below share: its last line fetches the engine, so they find it
there. `INVPW_E2E_SOURCE=git` swaps the block's `uv add` for the
unpublished commit - a pre-release check, not the default, and it is the
one line this file changes.
"""
return _make_venv(workspace / "venv")
lines = readme_install_block()
if os.environ.get("INVPW_E2E_SOURCE", "index") == "git":
add = [i for i, line in enumerate(lines) if line.split()[:3] == ["uv", "add", DIST]]
assert len(add) == 1, lines
lines[add[0]] = f'uv add "{DIST} @ git+{REPO_URL}@{REV}"'
home = workspace / "home"
home.mkdir(exist_ok=True)
run_readme_block(lines, cwd=workspace, home=home, env=isolated_cache_env)
cd = [line.split(maxsplit=1)[1] for line in lines if line.split()[:1] == ["cd"]]
assert len(cd) == 1, f"the block has to enter its project once: {lines}"
py = _venv_python(workspace / cd[0] / ".venv")
assert py.exists(), f"the README's block made no venv at {py}"
return py
@pytest.fixture(scope="module")
@@ -224,8 +285,8 @@ def isolated_cache_env(workspace: Path) -> dict:
@pytest.mark.e2e
def test_clean_install_the_way_a_user_does_it(clean_venv: Path):
"""`pip install invisible-playwright`, from the index, into an empty venv.
def test_clean_install_the_way_a_user_does_it(clean_venv: Path, workspace: Path):
"""The README's install block, from the index, into a project uv made.
THIS USED TO INSTALL FROM A GIT URL, and that stopped being anybody's
install path on 2026-07-26 when the three packages went to PyPI. A test
@@ -255,14 +316,8 @@ def test_clean_install_the_way_a_user_does_it(clean_venv: Path):
not here because this whole suite runs on an EDITABLE install of the
working tree, where every file exists on disk by definition.
"""
source = os.environ.get("INVPW_E2E_SOURCE", "index")
if source == "git":
target = f"git+{REPO_URL}@{REV}"
else:
target = "invisible-playwright"
_run([str(clean_venv), "-m", "pip", "install", "--no-cache-dir", target],
timeout=900)
# The install already happened, in the fixture, as the README's lines.
#
# NOT followed by a manual `pip install playwright==<pin>`. It used to be,
# and that line was hiding the thing this test exists to find: if the
# declared range resolves to a client the shipped Juggler cannot speak,
@@ -284,11 +339,22 @@ def test_clean_install_the_way_a_user_does_it(clean_venv: Path):
)
assert "OK invisible_playwright" in out.stdout, out.stdout
# pip's own consistency check. It is only meaningful because the core is
# declared as an exact version rather than a direct URL: a direct reference
# carries no version, so there is nothing here to compare and this reports
# clean on a broken environment.
_run([str(clean_venv), "-m", "pip", "check"], timeout=120)
# The installer's own consistency check (a venv uv made has no pip). It is
# only meaningful because the core is declared as an exact version rather
# than a direct URL: a direct reference carries no version, so there is
# nothing here to compare and this reports clean on a broken environment.
uv = _home_bin(workspace / "home") / ("uv.exe" if os.name == "nt" else "uv")
_run([str(uv), "pip", "check", "--python", str(clean_venv)], timeout=120)
# The block's project floor is the package's: a README asking `uv init`
# for a Python older than `requires-python` makes `uv add` fail on every
# machine whose default interpreter is that old (measured 2026-10-17: a
# project on 3.10 cannot add this package).
import tomllib
floor = tomllib.loads((README.parent / "pyproject.toml").read_text(
encoding="utf-8"))["project"]["requires-python"]
init = [line for line in readme_install_block() if line.split()[:2] == ["uv", "init"]]
assert len(init) == 1 and f'--python "{floor}"' in init[0], (init, floor)
@pytest.mark.e2e
+5 -4
View File
@@ -106,8 +106,9 @@ def stub_core(tmp_path: Path, *, with_seal: bool, version: str | None = None,
# only; newer ones carry `pin.py` plus a two-line `sys.modules` alias at
# `_pin.py`. Copying `pin.py` unconditionally made this whole file fail
# against a published core that predated it - eight tests, and the stub was
# never built.
for name in ("pin.py", "_pin.py"):
# never built. `installer.py` likewise, from 49.45.0, where `pin.py`
# imports it at load: without it the stub dies on its first line.
for name in ("pin.py", "_pin.py", "installer.py"):
if (CORE_PKG / name).exists():
shutil.copy2(CORE_PKG / name, pkg / name)
assert (pkg / "_pin.py").exists(), (
@@ -185,7 +186,7 @@ def test_import_fails_loudly_when_the_core_has_no_seal(tmp_path):
err = " ".join(r.stderr.split())
assert "ImportError" in r.stderr, r.stderr
assert "invisible_core.seal" in err, err
assert "pip install" in err, err
assert _pin.reinstall_command() in err, err
def test_a_core_whose_seal_json_is_gone_gets_the_message_not_a_traceback(tmp_path):
@@ -207,7 +208,7 @@ def test_a_core_whose_seal_json_is_gone_gets_the_message_not_a_traceback(tmp_pat
err = " ".join(r.stderr.split())
assert "ImportError" in err, err
assert "seal.json" in err, err
assert "pip install --force-reinstall invisible-playwright" in err, err
assert _pin.reinstall_command() in err, err
assert not re.search(r"invisible-core==\d", err), err
+1 -1
View File
@@ -32,7 +32,7 @@ from invisible_playwright._session import build_prefs
def _prefs(**kw):
base = dict(profile=generate_profile(42, None), locale="en-US",
timezone="", extra_prefs=None,
timezone="America/New_York", extra_prefs=None,
virtual_display=False, cursor_engine=ENGINE_PYTHON,
humanize=True, session_seed=42)
base.update(kw)
@@ -0,0 +1,60 @@
"""The floor's one remedy is spelled by the tool that installed this package.
`_pin.reinstall_command` is the reinstall line the import floor prints when
invisible-core cannot be imported at all, which is why it cannot ask the core's
`installer` module and reads the INSTALLER record itself. Measured 2026-10-17:
the venv the README makes (`uv init` + `uv add`) has no pip in it, and the line
was `pip install --force-reinstall` for everybody.
"""
from __future__ import annotations
import importlib.metadata
import sys
import pytest
from invisible_playwright import _pin
class _Dist:
def __init__(self, record):
self._record = record
def read_text(self, name):
assert name == "INSTALLER", name
return self._record
@pytest.mark.parametrize("record", ["uv\n", "UV", " uv "])
def test_an_environment_uv_built_is_told_uv(monkeypatch, record):
monkeypatch.setattr(importlib.metadata, "distribution", lambda name: _Dist(record))
line = _pin.reinstall_command()
assert line.startswith("uv pip install --python "), line
assert line.endswith("--force-reinstall invisible-playwright"), line
assert "-m pip" not in line, line
@pytest.mark.parametrize("record", ["pip\n", "poetry\n", None])
def test_any_other_environment_is_told_its_own_pip(monkeypatch, record):
monkeypatch.setattr(importlib.metadata, "distribution", lambda name: _Dist(record))
line = _pin.reinstall_command()
assert " -m pip install --force-reinstall invisible-playwright" in line, line
assert not line.startswith("uv "), line
def test_a_package_with_no_record_at_all_is_told_pip(monkeypatch):
def missing(name):
raise importlib.metadata.PackageNotFoundError(name)
monkeypatch.setattr(importlib.metadata, "distribution", missing)
assert " -m pip install --force-reinstall invisible-playwright" in _pin.reinstall_command()
def test_the_command_names_this_interpreter(monkeypatch):
"""A bare `pip` or `python` is whatever a shell finds first; the line has to
land in the environment whose import just failed."""
for record in ("uv", "pip"):
monkeypatch.setattr(importlib.metadata, "distribution",
lambda name, r=record: _Dist(r))
line = _pin.reinstall_command()
assert sys.executable in line or f'"{sys.executable}"' in line, line
+6 -1
View File
@@ -1,9 +1,14 @@
"""What happens to somebody who ALREADY has this installed.
Every install test next door starts from an empty venv, which is the path a new
Every install test next door starts from nothing, which is the path a new
user takes exactly once. Every existing user takes a different one - `pip
install -U`, or an environment that has drifted - and none of it was covered.
Pip ON PURPOSE, while the install test next door follows the README's uv
block: until 2026-10-17 the README said `pip install`, so the people who
already have this package are in pip-made venvs, and theirs is the upgrade
being tested.
That matters more here than in most packages, because of the shape of the
coupling: the wrapper declares an EXACT `invisible-core==X.Y.Z`, so an upgrade
has to move two distributions in step, and a half-moved environment is repaired
+1 -1
View File
@@ -226,7 +226,7 @@ from invisible_core.prefs import translate_profile_to_prefs # noqa: E402
@pytest.mark.unit
def test_shipped_webrtc_baseline_is_the_validated_config():
prefs = translate_profile_to_prefs(generate_profile(seed=42))
prefs = translate_profile_to_prefs(generate_profile(seed=42), timezone="America/New_York")
# host candidate must be mDNS .local like vanilla Firefox (manually
# validated on BrowserLeaks/CreepJS through a residential proxy) - not a
# raw LAN IP.