Skip to content

Commit f681799

Browse files
committed
Update html2print.py
1 parent 343b7f2 commit f681799

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

.github/workflows/ci-linux-ubuntu-latest.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ jobs:
4848
run: |
4949
invoke build
5050
51+
- name: Debug Chrome Version issue
52+
run: |
53+
/usr/bin/google-chrome-stable --version
54+
/usr/bin/google-chrome-stable --version
55+
5156
- name: Run tests
5257
run: |
5358
invoke test

html2print/html2print.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import browsers
1717
import requests
18-
from requests import Response, RequestException
18+
from requests import RequestException, Response
1919
from selenium import webdriver
2020
from selenium.webdriver.chrome.options import Options
2121
from selenium.webdriver.chrome.service import Service
@@ -41,7 +41,9 @@
4141

4242
class ChromeDriverManager:
4343
def get_chrome_driver(self, path_to_cache_dir: str):
44-
chrome_version = self.get_chrome_version()
44+
chrome_browser_info = browsers.get("chrome")
45+
chrome_version = chrome_browser_info["version"]
46+
chrome_path = chrome_browser_info["path"]
4547

4648
# If Web Driver Manager cannot detect Chrome, it returns None.
4749
if chrome_version is None:
@@ -55,6 +57,9 @@ def get_chrome_driver(self, path_to_cache_dir: str):
5557
print( # noqa: T201
5658
f"html2print: Installed Chrome version: {chrome_version}"
5759
)
60+
print( # noqa: T201
61+
f"html2print: Installed Chrome path: {chrome_path}"
62+
)
5863

5964
system_map = {
6065
"Windows": "win32",
@@ -181,8 +186,9 @@ def send_http_get_request(url, params=None, **kwargs) -> Response:
181186
f"html2print: "
182187
f"failed to get response for URL: {url} with error: {last_error}"
183188
)
184-
raise RequestException(f"GET request failed after 3 attempts: {url}") from last_error
185-
189+
raise RequestException(
190+
f"html2print: GET request failed after 3 attempts: {url}"
191+
) from last_error
186192

187193
@staticmethod
188194
def get_chrome_version():
@@ -329,7 +335,12 @@ def create_webdriver(
329335
else:
330336
service = Service(path_to_chrome)
331337

338+
path_to_chrome_browser = ""
339+
path_to_chrome_browser = browsers.get("chrome")["path"]
340+
print(f"html2print: Chrome available at path: {path_to_chrome_browser}") # noqa: T201
341+
332342
webdriver_options = Options()
343+
webdriver_options.binary_location = path_to_chrome_browser
333344
webdriver_options.add_argument("start-maximized")
334345
webdriver_options.add_argument("disable-infobars")
335346
# Doesn't seem to be needed.
@@ -462,7 +473,7 @@ def main():
462473
if browsers.get("chrome") is not None:
463474
path_to_chrome_browser = browsers.get("chrome")["path"]
464475
print( # noqa: T201
465-
f"html2print: Chrome available at path:{path_to_chrome_browser}"
476+
f"html2print: Chrome available at path: {path_to_chrome_browser}"
466477
)
467478
sys.exit(0)
468479

0 commit comments

Comments
 (0)