ruby-on-railscapybara

Capybara Element returned by Find method is taking a wrong coordinate


I have running a System Test with Ruby On Rails and Minitest, but an error is shown.

Error: RequestsTest#test_Admin_User_should_create_request: Selenium: :WebDriver: :Error: :ElementClickInterceptedError: element click intercepted: Element input-tag box#itemsClick">... is not clickable at point (686, 23). Other element would receive the click: … (Session info: chrome=120.0.6099.130) test/system/requests_test.rb:480:in execute_test_new_request' test/system/requests_test.rb:54:in block in class:RequestsTest'

HTML:

<a id="request__tags-list" href="#" class="input-tag-items" data-action="click->input-tag-box#itemsClick"></a>

My Test:

tags_list = find("#request__tags-list")
puts tags_list.rect
tags_list.click  # click on link

I tried using click_link method but it didn't work either. The same error is shown.

I noticed that "tags_list.rect" prints coordinates that do not correspond to the tags_list coordinates.

#<struct Selenium::WebDriver::Rectangle x=316.6037902832031, y=31.733491897583008, width=739, height=20>

when in reality, the Y coordinate is much further down the page, 480 approximately.

Some idea what is happening.

Thanks!

SO: Windows 11

Ruby Version: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]

Rails Version: Rails 7.0.8

UPDATE:

Screenshoot: enter image description here


Solution

  • The problem was that I had configure the laptop resolution screen at 125% when I bought it. For some reason Chrome calculate wrong the elements coordinates. This don't happen using Firefox.

    The coordinates are shown correctly now:

    #<struct Selenium::WebDriver::Rectangle x=315.7134704589844, y=347.7594451904297, width=738, height=20>
    

    Beartech, thank you by your help.