This is how we can execute a JavaScript function on a web page with Watir test automation framework.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir' | |
def calljs(function_name, function_params) | |
browser = Watir::Browser.new | |
cmd = "javascript:" + function_name + "(" + function_params + ");" | |
browser.document.parentWindow.execScript(cmd) | |
end |