|
13 | 13 | from time import sleep |
14 | 14 | from typing import Dict, List, Optional |
15 | 15 |
|
| 16 | +import browsers |
16 | 17 | import requests |
17 | 18 | from requests import Response |
18 | 19 | from selenium import webdriver |
@@ -332,7 +333,9 @@ def create_webdriver( |
332 | 333 | # Doesn't seem to be needed. |
333 | 334 | # webdriver_options.add_argument('--disable-gpu') # noqa: ERA001 |
334 | 335 | webdriver_options.add_argument("--disable-extensions") |
335 | | - webdriver_options.add_argument("--headless=chrome") |
| 336 | + # Use --headless=new, as it seems to be more stable on Windows (available since Chrome 109). |
| 337 | + # see https://www.selenium.dev/blog/2023/headless-is-going-away/ |
| 338 | + webdriver_options.add_argument("--headless=new") |
336 | 339 | # FIXME: This is not nice but otherwise it does not work in Ubuntu 24-based Docker image. |
337 | 340 | # https://github.com/SeleniumHQ/selenium/issues/15327#issuecomment-2689287561 |
338 | 341 | webdriver_options.add_argument("--no-sandbox") |
@@ -447,10 +450,18 @@ def main(): |
447 | 450 | args.cache_dir if args.cache_dir is not None else DEFAULT_CACHE_DIR |
448 | 451 | ) |
449 | 452 |
|
450 | | - path_to_chrome = ChromeDriverManager().get_chrome_driver( |
| 453 | + path_to_chrome_driver = ChromeDriverManager().get_chrome_driver( |
451 | 454 | path_to_cache_dir |
452 | 455 | ) |
453 | | - print(f"html2print: ChromeDriver available at path: {path_to_chrome}") # noqa: T201 |
| 456 | + print( # noqa: T201 |
| 457 | + f"html2print: ChromeDriver available at path: {path_to_chrome_driver}" |
| 458 | + ) |
| 459 | + |
| 460 | + if browsers.get("chrome") is not None: |
| 461 | + path_to_chrome_browser = browsers.get("chrome")["path"] |
| 462 | + print( # noqa: T201 |
| 463 | + f"html2print: Chrome available at path:{path_to_chrome_browser}" |
| 464 | + ) |
454 | 465 | sys.exit(0) |
455 | 466 |
|
456 | 467 | elif args.command == "print": |
|
0 commit comments