1515
1616import browsers
1717import requests
18- from requests import Response , RequestException
18+ from requests import RequestException , Response
1919from selenium import webdriver
2020from selenium .webdriver .chrome .options import Options
2121from selenium .webdriver .chrome .service import Service
4141
4242class 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 :
@@ -52,6 +54,9 @@ def get_chrome_driver(self, path_to_cache_dir: str):
5254
5355 chrome_major_version = chrome_version .split ("." )[0 ]
5456
57+ print ( # noqa: T201
58+ f"html2print: Installed Chrome path: { chrome_path } "
59+ )
5560 print ( # noqa: T201
5661 f"html2print: Installed Chrome version: { chrome_version } "
5762 )
@@ -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"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