SergeyPirogov / webdriver_manager

Apache License 2.0
2.02k stars 454 forks source link

`DriverCacheManager._cache_key_driver_version` is unused #661

Open GaspardCulis opened 2 months ago

GaspardCulis commented 2 months ago

The DriverCacheManager initializes its _cache_key_driver_version to None, and it never gets updated in the code. This means that even with a DriverCacheManager you still have to fetch the remote driver version which can lead to API rate limit errors.

To avoid running into these kinds of issues when having to run GeckoDriverManager().install() multiple times I'm currently using this dirty workaround:

from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.core.driver_cache import DriverCacheManager

cache = DriverCacheManager()
cache._cache_key_driver_version = "v0.34.0"
driver_path = GeckoDriverManager(cache_manager=cache).install()

But it's not ideal. I guess the DriverCacheManager should assume that the desired driver version is the OS browser version (get_browser_version_from_os)

izharus commented 1 month ago

I noticed the same thing. The install() method, therefore, always requires network access. Perhaps it would be worth adding another method alongside install(), such as get_cached_binary(), which would simply extract the latest driver from the cache? To achieve this, we only need to implement one method in DriverCacheManager, I can do it.