SeleniumHQ/selenium · error · ArgumentError
expected #{point.inspect}:#{point.class} to respond to #x an
Error message
expected #{point.inspect}:#{point.class} to respond to #x and #y What it means
Raised by Window#position= (ArgumentError) when the point argument does not respond to both #x and #y. The setter validates via respond_to? then calls bridge.reposition_window with point.x, point.y.
Source
Thrown at rb/lib/selenium/webdriver/common/window.rb:64
#
# Get the size of the current window.
#
# @return [Selenium::WebDriver::Dimension] The size.
#
def size
@bridge.window_size
end
#
# Move the current window to the given position.
#
# @param [Selenium::WebDriver::Point, #x and #y] point The new position.
#
def position=(point)
unless point.respond_to?(:x) && point.respond_to?(:y)
raise ArgumentError, "expected #{point.inspect}:#{point.class} " \
'to respond to #x and #y'
end
@bridge.reposition_window point.x, point.y
end
#
# Get the position of the current window.
#
# @return [Selenium::WebDriver::Point] The position.
#
def position
@bridge.window_position
end
#
# Sets the current window rect to the given point and position.View on GitHub (pinned to aa36b38e69)
Solutions
- Pass Selenium::WebDriver::Point.new(x, y), or any object exposing x and y readers.
- Use driver.manage.window.move_to(x, y) if available, which takes positional integers.
- Ensure any custom geometry object defines attr_reader :x, :y.
Example fix
// before driver.manage.window.position = [100, 200] // after driver.manage.window.position = Selenium::WebDriver::Point.new(100, 200)
Defensive patterns
Strategy: type-guard
Validate before calling
def point_like?(obj) obj.respond_to?(:x) && obj.respond_to?(:y) end raise ArgumentError, 'invalid point' unless point_like?(pt) driver.manage.window.position = pt
Type guard
def point_like?(obj) obj.respond_to?(:x) && obj.respond_to?(:y) end
Prevention
- Pass Selenium::WebDriver::Point.new(x, y) instead of arrays or hashes.
- Use positional move_to(x, y) if you only have integer coordinates.
- Verify any custom geometry object defines x and y readers.
When it happens
Trigger: Calling driver.manage.window.position = [0, 0] (Array), a hash {x:, y:}, an integer pair, or nil instead of a Point/object with x and y methods.
Common situations: Passing a coordinate array as with other windowing libraries; using a struct or OpenStruct that defines different accessor names; passing nil from a computation that returned no value.
Related errors
- expected #{dimension.inspect}:#{dimension.class} to respond
- expected #{rectangle.inspect}:#{rectangle.class} to respond
- Valid types are :tab and :window, received: #{type.inspect}
- incompatible proxy type #{type.inspect} (already set to #{@t
- cannot find element by #{how.inspect}
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/93cd1e5265f2532d.
Report an issue: GitHub.