How to click on a Bootstrap 5 range field at a given positional value with Capybara-Selenium?

20 views Asked by At

I'm using Bootstrap 5.3 range min-max field and RSpec Rails Capybara with Selenium.

In my RSpec Rails system test, I would like to simulate a click on a "positional value", say positional value 4 of a range with min 0 and max 5.

That is, given I've the following range field: enter image description here

Then I would like to spec-test click that range field so to get: enter image description here

How to do that using Capybara-Selenium?


Without success, I tried to spec-test click on input field at coordinates:

range_input = find("#customRange2")
input_rect = element.evaluate_script("this.getBoundingClientRect()") # => {"bottom"=>955.2000122070312, "height"=>22, "left"=>103, "right"=>1177, "top"=>933.2000122070312, "width"=>1074, "x"=>103, "y"=>933.2000122070312}
click_coordinate_x = ... # using input_rect
click_coordinate_y = ... # using input_rect
range_input.click(click_coordinate_x, click_coordinate_y)
0

There are 0 answers