Capybara/Selenium: evaluate_script might freeze your browser, use execute_script
In a nutshell: Do not use
While you can use both, the first line (with
evaluate_script) might freeze your Firefox window for 10 seconds.
The reason is that
evaluate_script will always return a result. The return value will be converted back to Ruby objects, which in case of complex objects (e.g. a jQuery collection) is very expensive.
Now that you know this, just forget that
evaluate_script ever existed and use
In cases where you don't care about the return value, it will just run the command. When you do need a return value, simply
page.execute_script("return 2 + 3") # => 5
Many Bothan spies have died to bring you this card.