Skip to content

Commit eec947d

Browse files
committed
Fix for Playwright 1.58, closes #189
1 parent 90dabf8 commit eec947d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

shot_scraper/cli.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,17 +409,22 @@ def _browser_context(
409409
auth_password=None,
410410
record_har_path=None,
411411
):
412-
browser_kwargs = dict(
413-
headless=not interactive, devtools=devtools, args=browser_args
414-
)
412+
# Playwright 1.58 removed the `devtools` launch option. Emulate the
413+
# previous behavior for Chromium by passing the corresponding flag.
414+
args = list(browser_args or [])
415+
browser_kwargs = dict(headless=not interactive, args=args)
415416
if browser == "chromium":
417+
if devtools and "--auto-open-devtools-for-tabs" not in args:
418+
args.append("--auto-open-devtools-for-tabs")
416419
browser_obj = p.chromium.launch(**browser_kwargs)
417420
elif browser == "firefox":
418421
browser_obj = p.firefox.launch(**browser_kwargs)
419422
elif browser == "webkit":
420423
browser_obj = p.webkit.launch(**browser_kwargs)
421424
else:
422425
browser_kwargs["channel"] = browser
426+
if devtools and "--auto-open-devtools-for-tabs" not in args:
427+
args.append("--auto-open-devtools-for-tabs")
423428
browser_obj = p.chromium.launch(**browser_kwargs)
424429
context_args = {}
425430
if auth:

0 commit comments

Comments
 (0)