Skip to content

Commit f9e1cfa

Browse files
committed
fix(stealth): remove unsupported focus option
1 parent 09a703d commit f9e1cfa

7 files changed

Lines changed: 8 additions & 10 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "webskrap"
7-
version = "0.5.4"
7+
version = "0.5.5"
88
description = "A Playwright-based Python scraping framework with coherent browser profiles and session controls."
99
readme = "README.md"
1010
requires-python = ">=3.11"

src/webskrap/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
OutputFormat = Literal["human", "json"]
3131
INSTALL_COMMANDS = (
3232
(sys.executable, "-m", "playwright", "install", "chromium"),
33-
("patchright", "install", "chromium"),
33+
(sys.executable, "-m", "patchright", "install", "chromium"),
3434
)
3535

3636

src/webskrap/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def context_options(self, profile: BrowserProfile) -> dict[str, Any]:
273273
# real fingerprint. The default keeps the host/browser environment
274274
# visible. The opt-in context profile below only applies settings
275275
# Chrome can expose natively through BrowserContext options.
276-
options: dict[str, Any] = {"no_viewport": True, "focus_control": False}
276+
options: dict[str, Any] = {"no_viewport": True}
277277
if self.patchright_context_profile:
278278
options.update(
279279
{

tests/test_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def fake_run(command: tuple[str, ...], **_kwargs: Any) -> subprocess.CompletedPr
158158

159159
def test_install_json_failure(monkeypatch: Any) -> None:
160160
def fake_run(command: tuple[str, ...], **_kwargs: Any) -> subprocess.CompletedProcess[str]:
161-
return_code = 1 if command[0] == "patchright" else 0
161+
return_code = 1 if "patchright" in command else 0
162162
return subprocess.CompletedProcess(
163163
command,
164164
return_code,
@@ -180,7 +180,7 @@ def fake_run(command: tuple[str, ...], **_kwargs: Any) -> subprocess.CompletedPr
180180

181181
def test_install_json_handles_missing_executable(monkeypatch: Any) -> None:
182182
def fake_run(command: tuple[str, ...], **_kwargs: Any) -> subprocess.CompletedProcess[str]:
183-
if command[0] == "patchright":
183+
if "patchright" in command:
184184
raise FileNotFoundError("missing patchright")
185185
return subprocess.CompletedProcess(command, 0, stdout="installed", stderr="")
186186

@@ -206,6 +206,6 @@ def fake_run(command: tuple[str, ...], **_kwargs: Any) -> subprocess.CompletedPr
206206
assert result.exit_code == 0, result.output
207207
assert "OK:" in result.output
208208
assert "playwright" in result.output
209+
assert "patchright" in result.output
209210
assert "install" in result.output
210211
assert "chromium" in result.output
211-
assert "patchright install chromium" in result.output

tests/test_models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def test_patchright_context_omits_profile_by_default() -> None:
6161
options = config.context_options(profile)
6262

6363
assert options["no_viewport"] is True
64-
assert options["focus_control"] is False
6564
assert "user_agent" not in options
6665
assert "extra_http_headers" not in options
6766

@@ -84,7 +83,6 @@ def test_patchright_context_profile_applies_native_context_metadata() -> None:
8483
options = config.context_options(profile)
8584

8685
assert options["no_viewport"] is True
87-
assert options["focus_control"] is False
8886
assert options["locale"] == "en-US"
8987
assert options["timezone_id"] == "Europe/Paris"
9088
assert options["color_scheme"] == "dark"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/content/user-guide/stealth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ config = SessionConfig(
3131
Patchright works best with real Chrome and a persistent context. If
3232
`user_data_dir` is omitted, WebSkrap creates a temporary persistent profile for
3333
Patchright sessions. Patchright contexts use the browser's real viewport and
34-
disable synthetic focus control (`no_viewport=True`, `focus_control=False`).
34+
avoid synthetic viewport overrides (`no_viewport=True`).
3535

3636
## Context profile mode
3737

0 commit comments

Comments
 (0)