Closed nikriek closed 5 years ago
Switching to browser: :remote
is also working for the current setup. However, when calling the network_conditions
, it returns
*** NoMethodError Exception: undefined method `network_conditions' for #<Selenium::WebDriver::Remote::Driver:0x00005599f4e652b0>
To prove my point I patched the paths. This makes it work:
module Selenium
module WebDriver
module Chrome
module Bridge
PATCHED_COMMANDS = {
get_network_conditions: [:get, 'session/:session_id/chromium/network_conditions'],
set_network_conditions: [:post, 'session/:session_id/chromium/network_conditions'],
send_command: [:post, 'session/:session_id/goog/cdp/execute']
}.freeze
def commands(command)
PATCHED_COMMANDS[command] || super
end
end
end
end
end
Thank you for a great bug report and a provided fix. I've committed and it will be released in the next 4.0 alpha.
This is also released in 3.142.2.
π Bug Report
We use a combination of docker-compose, rails and selenium to perform integration/system testing. The Capybara/rspec environment is supposed to send commands to a remote chrome container:
This is how we setup the driver:
This setup works completely fine. Capybara connects to the hub and successfully runs our integration tests.
In order to enhance our tests, we need to make use of the
network_conditions
selenium endpoint to test the application in an offline setup. This seems not to be officially documented, but it can be achieved using this call:Instead of returning a success, the call throws an exception:
To Reproduce
You can reproduce the issue by using a custom remote host in the Rails application.
Expected behavior
The expected behavior is a successful call for
The call expects a json response from
POST http://<HOST>:4444/wd/hub/session/e1fa22b0aaac7e5207d7bbe497673f57/chromium/network_conditions
I suspect the issue to be a problem of absolute and relative url paths in the chrome bride: https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/chrome/bridge.rb#L27
Other calls to the api (like for creating a new session) do not have a
/
appended. It seems that the call is going toPOST http://<HOST>:4444/session/e1fa22b0aaac7e5207d7bbe497673f57/chromium/network_conditions
Test script or set of commands reproducing this issue
See above
Environment
OS: Linux 4.9.125-linuxkit / Docker Browser: chrome Browser version: chromedriver=74.0.3729.6 Browser Driver version: Language Bindings version: Ruby 2.5.2