From a582038465e36a2571d6235143c4377120dcb2e3 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Wed, 9 Oct 2024 14:29:51 +0200 Subject: [PATCH] Return driver object only when valid Without this, a driver that failed the sanity check could be returned. This leads to attempting to use it when checking URLs, which led to avoidable failures. Fixes #92 --- urlchecker/core/urlproc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/urlchecker/core/urlproc.py b/urlchecker/core/urlproc.py index 125ad0b..6f1eec5 100644 --- a/urlchecker/core/urlproc.py +++ b/urlchecker/core/urlproc.py @@ -153,10 +153,11 @@ def get_driver(self, port: Optional[int] = None, timeout: Optional[int] = 5): try: from .webdriver import WebDriver - driver = WebDriver(port=port, timeout=timeout) + default_driver = WebDriver(port=port, timeout=timeout) - # Do a sanity check of the driver - driver.check("https://google.com") + # Do a sanity check of the default driver + default_driver.check("https://google.com") + driver = default_driver except: logger.warning( "Issue with driver, results will be improved if you have it! Please match your version from https://googlechromelabs.github.io/chrome-for-testing"