Google Chrome 61.xx bit my finger :) – Element not clickable at point error in Capybara

Google Chrome 61.xx bit my finger :) – Element not clickable at point error in Capybara

My test suite is failing due to the latest changes in Google Chrome version (61.xx), seems like something has changed and now you need to manually scroll right/bottom/top if you are using Capybara RSpec or cucumber with selenium driver because if the element is not visible you will face the error:

Element not clickable at point

In case you’re running your test suite in circle ci or codeship.io or any other continuous integration service, once they update the current version you will face the same problem and actually, you don’t need to wait for that as you can install the latest stable version, doing something like the included in the following gist:
https://gist.github.com/Arjeno/8564d9643f16d072a85b9c9b5a9f7de0

So in order to fix that I’m using some useful helpers and step definitions:

If you are using cucumber:

# usage example: features/step_definitions/user_steps.rb
# When I scroll "1000" px to the bottom of the page
When(/^I scroll "(.*?)" px to the bottom of the page$/) do |number_pixels|
  page.execute_script "window.scrollBy(0, #{number_pixels})"
end

Then(/^I scroll to the bottom of the page$/) do
  page.execute_script 'window.scrollBy(0,10000)'
end

Then(/^I scroll to the right of the page$/) do
  page.execute_script 'window.scrollBy(20000,0)'
end

Then(/^I scroll to the top of the page$/) do
  page.execute_script "window.location = '#'"
end

When using Capybara RSpec:

  def scroll_bottom_to(number_pixels)
    page.execute_script "window.scrollBy(0, #{number_pixels})"
  end

  def scroll_to_the_very_bottom
    page.execute_script 'window.scrollBy(0,10000)'
  end

  def scroll_to_the_very_right
    page.execute_script 'window.scrollBy(20000,0)'
  end

  def scroll_to_top
    page.execute_script "window.location = '#'"
  end

As you always keep reading, coding and relax.

No Comments

Post A Comment