Rails + Capybara: clicking link with evaluate_script freezes webdriver

capybara, ruby-on-rails

Solution

It's due to a bug in Selenium. Found the answer here: https://groups.google.com/forum/?fromgroups=#!topic/ruby-capybara/YcZwyPdMJFU

It doesn't hang when replacing `page.evaluate_script` with:

page.driver.browser.execute_script

Problem

I run the following in my `js: true` request spec: ``` page.evaluate_script("$('#sign-up').click();") ``` That opens the modal successfully. However, the webdriver freezes at that point, regardless of what comes next in the spec. After a long pause, I get: ``` Failure/Error: Timeout::Error: Timeout::Error # ./spec/requests/my_spec.rb:14:in `block (3 levels) in <top (required)>' ``` I want to use `evaluate_script` instead of 'click_on' in this case, because there is no `href` attribute on that particular link (click_on doesn't work). How do I get it to work without timing out?

Original source