-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Web driver is not installed, but seems to be required #92
Comments
Yes you are totally right, the driver should be set to None to avoid the error. This is being done in urlchecker-python/urlchecker/core/urlproc.py Line 152 in d0e7560
When the exception is raised the returned value should be none unless line 156 changes the driver value, which means you do have a driver but it doesn't pass the sanity check. @vsoch might have a better explanation for this. |
When it crashes like that, it's a mismatch between the chrome you have and the driver. |
Thanks for the prompt replies! This was running in a Docker container based on ubuntu 24.04, customized for building and linting some static HTML pages. There is no browser or similar, except as might have been brought in by
Yes, or to replace the driver by None if an exception was caught. |
This is easy to test, simply run this from within your docker from .webdriver import WebDriver
driver = WebDriver(port=port, timeout=timeout)
print(driver)
# Do a sanity check of the driver
driver.check("https://google.com") A more robust version of the function could be the following. def get_driver(self, port: Optional[int] = None, timeout: Optional[int] = 5):
"""
Get a selenium web driver for a check session, if possible.
Requires selenium driver to exit, fall back to not using
"""
detected_driver = None
try:
from .webdriver import WebDriver
driver = WebDriver(port=port, timeout=timeout)
# Do a sanity check of the driver
driver.check("https://google.com")
detected_driver = 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"
)
return detected_driver Feel free to submit a PR for this. |
You can also just mimic what we do in our own docker image: https://github.com/urlstechie/urlchecker-python/blob/master/Dockerfile |
I dropped in
and saw
yet I'll make a PR |
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 urlstechie#92
* 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
In a CI container where I have not installed a browser or web driver, I am trying to run urlchecker, but get an error message like
That makes it look like a driver is actually required.
If a driver is intended to be optional, then I think https://github.com/urlstechie/urlchecker-python/blob/master/urlchecker/core/urlproc.py#L161 should set
driver = None
so that https://github.com/urlstechie/urlchecker-python/blob/master/urlchecker/core/urlproc.py#L282 will not choke on an invalid driver.The text was updated successfully, but these errors were encountered: