SeleniumHQ/selenium · error · ArgumentError
Invalid arguments: #{opts.keys}
Error message
Invalid arguments: #{opts.keys} What it means
Raised as ArgumentError by Scroll#initialize when, after extracting the recognized kwargs (:x, :y, :delta_x, :delta_y), the remaining opts hash is non-empty. Recognized Scroll kwargs are: source (required), origin, duration, x, y, delta_x, delta_y. Anything else is rejected.
Source
Thrown at rb/lib/selenium/webdriver/common/interactions/scroll.rb:40
module Interactions
#
# Action related to scrolling a wheel.
#
# @api private
#
class Scroll < Interaction
def initialize(source:, origin: :viewport, duration: 0.25, **opts)
super(source)
@type = :scroll
@duration = duration * 1000
@origin = origin
@x_offset = opts.delete(:x) || 0
@y_offset = opts.delete(:y) || 0
@delta_x = opts.delete(:delta_x) || 0
@delta_y = opts.delete(:delta_y) || 0
raise ArgumentError, "Invalid arguments: #{opts.keys}" unless opts.empty?
end
def assert_source(source)
raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? WheelInput
end
def encode
{'type' => type.to_s,
'duration' => @duration.to_i,
'x' => @x_offset,
'y' => @y_offset,
'deltaX' => @delta_x,
'deltaY' => @delta_y,
'origin' => @origin.is_a?(Element) ? @origin : @origin.to_s}
end
end # PointerPress
end # Interactions
end # WebDriverView on GitHub (pinned to aa36b38e69)
Solutions
- Use only the recognized keys: origin, duration, x, y, delta_x, delta_y (plus source internally).
- For scroll_by use delta_x:/delta_y:; for scroll_from pass x:/y: via ScrollOrigin offsets and delta_x:/delta_y: for the scroll amount.
- Check for camelCase leaks — convert deltaX→delta_x, deltaY→delta_y.
Example fix
# before driver.action.scroll_by(100, 200, speed: 5).perform # => ArgumentError: Invalid arguments: [:speed] # or driver.action.scroll(deltaX: 100, deltaY: 200).perform # => ArgumentError: Invalid arguments: [:deltaX] # after driver.action.scroll_by(100, 200).perform
Defensive patterns
Strategy: validation
Validate before calling
ALLOWED = %i[source origin duration x y delta_x delta_y].freeze
unknown = opts.keys - ALLOWED
raise "unsupported scroll opts: #{unknown}" unless unknown.empty?
driver.action.scroll(**opts.slice(*ALLOWED)).perform Prevention
- Use snake_case kwargs: delta_x/delta_y (not deltaX/deltaY), and the right method per intent (scroll_by takes delta_x/delta_y).
- Do not pass unrelated options like speed/deceleration to the scroll DSL.
When it happens
Trigger: Calling wheel.create_scroll(...) or the public scroll/scroll_by/scroll_from/scroll_to DSL with an unrecognized key — e.g. scroll_by(100, 200, dx: 0) (should be delta_x:), scroll(deltaX: 100) (string key, or camelCase), or scroll_from(origin, 0, 200, speed: 5).
Common situations: camelCase vs snake_case confusion (deltaX vs delta_x); passing x/y to scroll_by (which takes delta_x/delta_y); typos; copy-paste from a JS example.
Related errors
- Unknown options found: #{@opts.inspect}
- #{button} is not a valid button!
- Button number cannot be negative!
- #{direction.inspect} is not a valid button direction
- #{source.type} is not a valid input type
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/f5bb6bf55cf78098.
Report an issue: GitHub.