{"record":{"id":"0f57056a70fd0bd9","repo":"SeleniumHQ/selenium","slug":"direction-inspect-is-not-a-valid-button-directi","errorCode":null,"errorMessage":"#{direction.inspect} is not a valid button direction","messagePattern":"#(.+?) is not a valid button direction","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/interactions/pointer_press.rb","lineNumber":78,"sourceCode":"        end\n\n        def assert_button(button)\n          case button\n          when Symbol\n            raise ArgumentError, \"#{button} is not a valid button!\" unless BUTTONS.key? button\n\n            BUTTONS[button]\n          when Integer\n            raise ArgumentError, 'Button number cannot be negative!' if button.negative?\n\n            button\n          else\n            raise TypeError, \"button must be a positive integer or one of #{BUTTONS.keys}, not #{button.class}\"\n          end\n        end\n\n        def assert_direction(direction)\n          raise ArgumentError, \"#{direction.inspect} is not a valid button direction\" unless DIRECTIONS.key? direction\n\n          DIRECTIONS[direction]\n        end\n      end # PointerPress\n    end # Interactions\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":60,"sourceCodeEnd":86,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/interactions/pointer_press.rb#L60-L86","documentation":"Raised as ArgumentError by PointerPress#assert_direction when the direction passed to PointerPress.new(source, direction, button, **) is not a key in DIRECTIONS. DIRECTIONS permits exactly :down (→ :pointerDown) and :up (→ :pointerUp).","triggerScenarios":"Constructing PointerPress with :press, :release, :click, 'down' (String), or :down? — anything outside {:down, :up}. Rarely user-facing because PointerInput#create_pointer_down / create_pointer_up hard-code the correct direction; only hit by direct PointerPress construction.","commonSituations":"Custom action-builder code or a port from another bindings language that names directions differently; passing a String instead of a Symbol.","solutions":["Use pointer_input.create_pointer_down / create_pointer_up so direction is set correctly.","If constructing PointerPress directly, pass exactly :down or :up."],"exampleFix":"# before\npress = Selenium::WebDriver::Interactions::PointerPress.new(pointer, :press, :left) # => ArgumentError\n\n# after\npress = Selenium::WebDriver::Interactions::PointerPress.new(pointer, :down, :left)","handlingStrategy":"validation","validationCode":"DIRECTIONS = Selenium::WebDriver::Interactions::PointerPress::DIRECTIONS\ndirection = direction.to_sym if direction.is_a?(String)\nraise \"unsupported direction: #{direction}\" unless DIRECTIONS.key?(direction)","typeGuard":"def valid_direction?(d)\n  Selenium::WebDriver::Interactions::PointerPress::DIRECTIONS.key?(d.is_a?(Symbol) ? d : d.to_sym)\nend","tryCatchPattern":null,"preventionTips":["Use create_pointer_down/create_pointer_up rather than constructing PointerPress with a direction.","If constructing directly, pass exactly :down or :up."],"tags":["interactions","pointer-press","argument-validation","internal-api","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}