teamcapybara/capybara · error · ArgumentError

Invalid scroll_to location: #{location}

Error message

Invalid scroll_to location: #{location}

What it means

Error "Invalid scroll_to location: #{location}" thrown in teamcapybara/capybara.

Source

Thrown at lib/capybara/selenium/extensions/scroll.rb:41

          scroll_to_location(location)
        else
          scroll_to_coords(*position)
        end
        self
      end

    private

      def scroll_element_to_location(element, location)
        scroll_opts = case location
        when :top
          'true'
        when :bottom
          'false'
        when :center
          "{behavior: 'instant', block: 'center'}"
        else
          raise ArgumentError, "Invalid scroll_to location: #{location}"
        end
        driver.execute_script <<~JS, element
          arguments[0].scrollIntoView(#{scroll_opts})
        JS
      end

      SCROLL_POSITIONS = {
        top: '0',
        bottom: 'arguments[0].scrollHeight',
        center: '(arguments[0].scrollHeight - arguments[0].clientHeight)/2'
      }.freeze

      def scroll_to_location(location)
        driver.execute_script <<~JS, self
          if (arguments[0].scrollTo){
            arguments[0].scrollTo(0, #{SCROLL_POSITIONS[location]});
          } else {
            arguments[0].scrollTop = #{SCROLL_POSITIONS[location]};

View on GitHub (pinned to 15b5fdb76e)

When it happens

Trigger: Thrown at lib/capybara/selenium/extensions/scroll.rb:41 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of teamcapybara/capybara@15b5fdb76e (2026-08-21). Data as JSON: /api/errors/e5b4c4848560faeb. Report an issue: GitHub.