titusfortner / webdrivers

Keep your Selenium WebDrivers updated automatically
MIT License
592 stars 113 forks source link

Offline environment #246

Closed noraj closed 1 year ago

noraj commented 1 year ago

Summary

I'm using Watir with webdrivers. When I'm on an environment without internet access I get the following on the client side:

An unhandled lowlevel error occurred. The application logs may have details.

On the server side I can read the following logs:

2023-03-16 13:45:46 +0000 Rack app ("POST /report" - (10.0.0.1)): #<Webdrivers::ConnectionError: Can not reach https://github.com/mozilla/geckodriver/releases/latest>

The app is just doing something like browser.goto 'http://10.0.0.1:8080' where of course http://10.0.0.1:8080 is available.

But it seems that webdrivers try to check for update on internet and fails if can't contact the upstream URL.

https://github.com/titusfortner/webdrivers#version-pinning

You can explicitly trigger the update in your code, but this will happen automatically when the driver is initialized:

Would that be possible to disable the update or not fails if it can't reach https://github.com/mozilla/geckodriver/releases/latest but just display a warning instead.

Debug Info

Please provide the following information for bug reports:

noraj commented 1 year ago

By reading https://github.com/titusfortner/webdrivers/blob/main/spec/webdrivers/geckodriver_spec.rb, I understand that I could potentially pre-download the binary for offline use and that would not trigger the ConnectionError?

https://github.com/titusfortner/webdrivers/blob/5b3dc29ff5cdb7bec110de949e78184c789ef63a/spec/webdrivers/geckodriver_spec.rb#L24C11-L32

noraj commented 1 year ago

I workarounded it with ruby -e "require 'webdrivers'; Webdrivers::Geckodriver.update" in my Dockerfile so that the image has a webdriver binary for gecko for offline use.

kapoorlakshya commented 1 year ago

Hey @noraj, in addition to downloading the driver during Docker build stage, it would also help to pin the version to whatever version is already downloaded. This should do it:

# Set required to currently available version
Webdrivers::Geckodriver.required_version  = Webdrivers::Geckodriver. current_version

That will ensure no network calls are attempted to check for or perform an update at run time. Feel free to close this issue if it solves the problem.