{"record":{"id":"7661e9914a10614c","repo":"SeleniumHQ/selenium","slug":"expected-rectangle-inspect-rectangle-class-t","errorCode":null,"errorMessage":"expected #{rectangle.inspect}:#{rectangle.class} to respond to #x, #y, #width, and #height","messagePattern":"expected #(.+?):#(.+?) to respond to #x, #y, #width, and #height","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/window.rb","lineNumber":89,"sourceCode":"      #\n      # Get the position of the current window.\n      #\n      # @return [Selenium::WebDriver::Point] The position.\n      #\n\n      def position\n        @bridge.window_position\n      end\n\n      #\n      # Sets the current window rect to the given point and position.\n      #\n      # @param [Selenium::WebDriver::Rectangle, #x, #y, #width, #height] rectangle The new rect.\n      #\n\n      def rect=(rectangle)\n        unless %w[x y width height].all? { |val| rectangle.respond_to? val }\n          raise ArgumentError, \"expected #{rectangle.inspect}:#{rectangle.class} \" \\\n                               'to respond to #x, #y, #width, and #height'\n        end\n\n        @bridge.set_window_rect(x: rectangle.x,\n                                y: rectangle.y,\n                                width: rectangle.width,\n                                height: rectangle.height)\n      end\n\n      #\n      # Get the rect of the current window.\n      #\n      # @return [Selenium::WebDriver::Rectangle] The rectangle.\n      #\n\n      def rect\n        @bridge.window_rect\n      end","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/window.rb#L71-L107","documentation":"Raised by Window#rect= (ArgumentError) when the rectangle argument does not respond to all of x, y, width, and height. Validation iterates %w[x y width height] through respond_to? before delegating to bridge.set_window_rect.","triggerScenarios":"Passing a Dimension (has width/height only), a Point (x/y only), a hash, an array, or a partial struct to driver.manage.window.rect =.","commonSituations":"Reusing a Dimension or Point object where a full Rectangle is required; passing a Hash with symbol keys (hashes don't respond to x/y/width/height as methods); constructing rects from JSON without wrapping in a Rectangle.","solutions":["Pass Selenium::WebDriver::Rectangle.new(x, y, width, height).","If you only have partial data, fill the missing fields (e.g. fetch current rect first and merge).","Avoid passing Hashes or Arrays; convert them into a Rectangle (or duck-typed object with all four accessors)."],"exampleFix":"// before\ndriver.manage.window.rect = {x: 0, y: 0, width: 800, height: 600}\n\n// after\ndriver.manage.window.rect = Selenium::WebDriver::Rectangle.new(0, 0, 800, 600)","handlingStrategy":"type-guard","validationCode":"def rectangle_like?(obj)\n  %w[x y width height].all? { |m| obj.respond_to?(m) }\nend\n\nraise ArgumentError, 'invalid rectangle' unless rectangle_like?(rect)\ndriver.manage.window.rect = rect","typeGuard":"def rectangle_like?(obj)\n  %w[x y width height].all? { |m| obj.respond_to?(m) }\nend","tryCatchPattern":null,"preventionTips":["Build Selenium::WebDriver::Rectangle.new(x, y, w, h) instead of hashes/arrays.","Don't reuse a Dimension or Point where a full Rectangle is required.","Validate all four accessors are present 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"}