Skip to content

Commit f80a371

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

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

html2print/html2print.py

Lines changed: 12 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,8 @@
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"]
4546

4647
# If Web Driver Manager cannot detect Chrome, it returns None.
4748
if chrome_version is None:
@@ -181,8 +182,9 @@ def send_http_get_request(url, params=None, **kwargs) -> Response:
181182
f"html2print: "
182183
f"failed to get response for URL: {url} with error: {last_error}"
183184
)
184-
raise RequestException(f"GET request failed after 3 attempts: {url}") from last_error
185-
185+
raise RequestException(
186+
f"html2print: GET request failed after 3 attempts: {url}"
187+
) from last_error
186188

187189
@staticmethod
188190
def get_chrome_version():
@@ -329,7 +331,12 @@ def create_webdriver(
329331
else:
330332
service = Service(path_to_chrome)
331333

334+
path_to_chrome_browser = ""
335+
path_to_chrome_browser = browsers.get("chrome")["path"]
336+
print(f"html2print: Chrome available at path: {path_to_chrome_browser}") # noqa: T201
337+
332338
webdriver_options = Options()
339+
webdriver_options.binary_location = path_to_chrome_browser
333340
webdriver_options.add_argument("start-maximized")
334341
webdriver_options.add_argument("disable-infobars")
335342
# Doesn't seem to be needed.
@@ -462,7 +469,7 @@ def main():
462469
if browsers.get("chrome") is not None:
463470
path_to_chrome_browser = browsers.get("chrome")["path"]
464471
print( # noqa: T201
465-
f"html2print: Chrome available at path:{path_to_chrome_browser}"
472+
f"html2print: Chrome available at path: {path_to_chrome_browser}"
466473
)
467474
sys.exit(0)
468475

0 commit comments

Comments
 (0)