{"record":{"id":"4fd2db99ba9eed52","repo":"SeleniumHQ/selenium","slug":"expected-dimension-inspect-dimension-class-t","errorCode":null,"errorMessage":"expected #{dimension.inspect}:#{dimension.class} to respond to #width and #height","messagePattern":"expected #(.+?):#(.+?) to respond to #width and #height","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/window.rb","lineNumber":39,"sourceCode":"  module WebDriver\n    class Window\n      #\n      # @api private\n      #\n\n      def initialize(bridge)\n        @bridge = bridge\n      end\n\n      #\n      # Resize the current window to the given dimension.\n      #\n      # @param [Selenium::WebDriver::Dimension, #width and #height] dimension The new size.\n      #\n\n      def size=(dimension)\n        unless dimension.respond_to?(:width) && dimension.respond_to?(:height)\n          raise ArgumentError, \"expected #{dimension.inspect}:#{dimension.class} \" \\\n                               'to respond to #width and #height'\n        end\n\n        @bridge.resize_window dimension.width, dimension.height\n      end\n\n      #\n      # Get the size of the current window.\n      #\n      # @return [Selenium::WebDriver::Dimension] The size.\n      #\n\n      def size\n        @bridge.window_size\n      end\n\n      #\n      # Move the current window to the given position.","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/window.rb#L21-L57","documentation":"Raised by Window#size= (ArgumentError) when the dimension argument does not respond to both #width and #height. The setter accepts any duck-typed object exposing those readers (typically Selenium::WebDriver::Dimension) and validates via respond_to? before delegating to bridge.resize_window.","triggerScenarios":"Calling driver.manage.window.size = [800, 600] (passing an Array), a hash, a single integer, or nil instead of a Dimension/object with width and height methods.","commonSituations":"Developers passing a two-element array or a struct lacking the expected accessor names; porting code from another binding whose window-size API takes (width, height) positional args; accidental nil from an uninitialized variable.","solutions":["Pass a Selenium::WebDriver::Dimension.new(width, height), or any object with width/height readers.","Prefer the positional helper driver.manage.window.resize_to(width, height) which coerces via Integer() and avoids the duck-type requirement.","If building a custom geometry object, ensure it defines attr_reader :width, :height."],"exampleFix":"// before\ndriver.manage.window.size = [1024, 768]\n\n// after\ndriver.manage.window.size = Selenium::WebDriver::Dimension.new(1024, 768)\n# or simply\ndriver.manage.window.resize_to(1024, 768)","handlingStrategy":"type-guard","validationCode":"def dimension_like?(obj)\n  obj.respond_to?(:width) && obj.respond_to?(:height)\nend\n\nraise ArgumentError, 'invalid dimension' unless dimension_like?(dim)\ndriver.manage.window.size = dim","typeGuard":"def dimension_like?(obj)\n  obj.respond_to?(:width) && obj.respond_to?(:height)\nend","tryCatchPattern":null,"preventionTips":["Prefer driver.manage.window.resize_to(width, height) which takes plain integers.","Construct Selenium::WebDriver::Dimension.new(w, h) rather than passing arrays/hashes.","Validate any geometry object exposes width/height before assigning."],"tags":["window","argument-error","duck-typing"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}