SeleniumHQ/selenium · error · ArgumentError

#{num} is not less than or equal to #{max}

Error message

#{num} is not less than or equal to #{max}

What it means

Raised as ArgumentError by PointerEventProperties.assert_number when a property value exceeds the property's documented maximum (only when VALID defines a max for that property). Maxima: pressure 1.0, tangential_pressure 1.0, tilt_x/tilt_y 90, twist 359, altitude_angle PI/2, azimuth_angle 2*PI. width/height have no max so this branch is skipped for them.

Source

Thrown at rb/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb:56

            next unless @opts.key?(key)

            name = val.keys.first
            values = val.values.first
            hash[name] = assert_number(@opts[key], values[:min], values[:max])
          end
        end

        private

        def assert_number(num, min, max = nil)
          return if num.nil?

          klass = min.is_a?(Integer) ? Integer : Numeric
          raise TypeError, "#{num} is not a #{klass}" unless num.is_a?(klass)

          raise ArgumentError, "#{num} is not greater than or equal to #{min}" if num < min

          raise ArgumentError, "#{num} is not less than or equal to #{max}" if max && num > max

          num
        end
      end # PointerEventProperties
    end # Interactions
  end # WebDriver
end # Selenium

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Clamp to the property's max with [val, max_val].min using the VALID table (twist max 359, tilt ±90, pressure/tangential_pressure ≤1, altitude ≤ π/2, azimuth ≤ 2π).
  2. Double-check units: altitude_angle and azimuth_angle are radians, not degrees.
  3. Use modulo where it makes physical sense (e.g. azimuth_angle: val % (2 * Math::PI)).

Example fix

# before
driver.action.pointer_down(:pen_contact, twist: 360).perform # => ArgumentError: 360 is not less than or equal to 359

# after
driver.action.pointer_down(:pen_contact, twist: 360 % 360).perform
Defensive patterns

Strategy: validation

Validate before calling

VALID = Selenium::WebDriver::Interactions::PointerEventProperties::VALID
def clamped_max(prop, val)
  return nil if val.nil?
  max = VALID[prop].values.first[:max]
  return val unless max
  val > max ? max : val
end

driver.action.pointer_down(:pen_contact, twist: clamped_max(:twist, computed)).perform

Prevention

When it happens

Trigger: Passing an out-of-range-high value: pressure: 1.1, tilt_x: 91, twist: 360, azimuth_angle: 7.0, altitude_angle: 2.0.

Common situations: Stylus automation with computed angles exceeding physical range; twist given as 0–360 then a value of exactly 360 (max is 359); radians-vs-degrees confusion for altitude/azimuth (these take radians, not degrees).

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/8151db45f1bf45b4. Report an issue: GitHub.