Method: Capybara::Session#evaluate_script

Defined in:
lib/capybara/session.rb

#evaluate_script(script, *args) ⇒ Object

Evaluate the given JavaScript and return the result. Be careful when using this with scripts that return complex objects, such as jQuery statements. #execute_script might be a better alternative.

Parameters:

  • script (String)

    A string of JavaScript to evaluate

  • args

    Optional arguments that will be passed to the script

Returns:

  • (Object)

    The result of the evaluated JavaScript (may be driver specific)



619
620
621
622
623
# File 'lib/capybara/session.rb', line 619

def evaluate_script(script, *args)
  @touched = true
  result = driver.evaluate_script(script.strip, *driver_args(args))
  element_script_result(result)
end