Reputation: 882
I have the following capybara config:
Capybara.register_driver :chrome_headless do |app|
media_tab_screen_size = '1280,800'
chrome_capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
loggingPrefs: {
browser: 'ALL',
client: 'ALL',
driver: 'ALL',
server: 'ALL'
},
chromeOptions: {
args: %W[no-sandbox
disable-dev-shm-usage
no-default-browser-check
start-maximized
headless
disable-gpu
window-size=#{media_tab_screen_size}]
}
)
if ENV['HUB_URL']
Capybara::Selenium::Driver.new(app,
browser: :remote,
url: ENV['HUB_URL'],
desired_capabilities: chrome_capabilities)
else
Capybara::Selenium::Driver.new(app,
browser: :chrome,
desired_capabilities: chrome_capabilities)
end
end
RSpec.configure do |config|
driven_by :chrome_headless
# Sets host for tests with selenium
Capybara.app_host = "http://#{IPSocket.getaddress(Socket.gethostname)}:3000"
# Capybara.server = :puma # Until your setup is working
Capybara.server_host = IPSocket.getaddress(Socket.gethostname)
Capybara.server_port = 3000
end
When I am running the system test using docker-compose and through selenium/standalone-chrome:88.0
image, I am getting the following error when I run the test like this:
docker-compose run --rm -e RAILS_ENV=test web bin/rails spec:system
ArgumentError:
wrong number of arguments (given 1, expected 0)
# /usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:44:in `handshake'
# /usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/driver.rb:39:in `initialize'
# /usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:58:in `new'
# /usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:58:in `for'
# /usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver.rb:88:in `for'
# /usr/local/bundle/gems/capybara-3.35.3/lib/capybara/selenium/driver.rb:83:in `browser'
# /usr/local/bundle/gems/capybara-3.35.3/lib/capybara/selenium/driver.rb:104:in `visit'
# /usr/local/bundle/gems/capybara-3.35.3/lib/capybara/session.rb:278:in `visit'
# /usr/local/bundle/gems/capybara-3.35.3/lib/capybara/dsl.rb:53:in `call'
# /usr/local/bundle/gems/capybara-3.35.3/lib/capybara/dsl.rb:53:in `visit'
# ./spec/system/home_page_spec.rb:7:in `block (2 levels) in <top (required)>'
# /usr/local/bundle/gems/webmock-3.11.2/lib/webmock/rspec.rb:37:in `block (2 levels) in <main>'
1.2) Failure/Error:
def self.handshake(**opts)
desired_capabilities = opts.delete(:desired_capabilities) { Capabilities.new }
if desired_capabilities.is_a?(Symbol)
unless Capabilities.respond_to?(desired_capabilities)
raise Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}"
end
desired_capabilities = Capabilities.__send__(desired_capabilities)
end
ArgumentError:
wrong number of arguments (given 1, expected 0)
I really don't know what is causing this, whether it is a configuration problem or a compatibility problem. I tried to debug it myriad times and change the gems version but nothing happened. I would appreciate any help.
Upvotes: 3
Views: 1924
Reputation: 49950
Looking at the code listed in your stacktrace, the remote driver is doing
def initialize(opts = {})
listener = opts.delete(:listener)
@bridge = Bridge.handshake(opts)
...
which is calling to the remote bridge code
def self.handshake(**opts)
desired_capabilities = opts.delete(:desired_capabilities) { Capabilities.new }
...
We can see from this that remote driver is passing a Hash, but handshake
is expecting keyword arguments. This would have worked in Ruby < 3.0 because the last Hash parameter would have been interpreted as keyword args (in Ruby 2.7 it would give a deprecation warning), but not in Ruby 3.0+, so I assume you're using Ruby 3.0 which isn't compatible with Selenium 3.x
Upvotes: 6