Need to click at a point on a map with Capybara? Now you can do it
Sep 1, 2018 · 1 min read
Testing my Rails projects I quite often needed to click on a point on a map. To select a location or checkin for example

Capybara 3 allows to do this with ease:
find('#map').click(x, y)
But Capybara 2 doesn’t have this functionality. Before upgrade to Capybara 3 I used handwritten click_at capybara helper
I decided to extract the helper code into a small library for the sake of consistency. It exposes click_at helper and uses Capybara 3 api under the hood if installed capybara version is greater than 3.0.0. Otherwise it fires 'click' Javascript event to achieve the result:
click_at(x, y) # click the page at (x, y)
click_at(x, y, css: '#map') # click map at (x, y)You can see more examples in the README. You can download the code from Rubygems
Happy testing!