How to Run JavaScript From Watir Scripts
What’s Watir? Read “Watir: Another sweetspot for Enterprise Ruby”
Is it possible to run JavaScript functions or execute code from within your Watir test scripts? As a matter of fact it is, but I had a hard time finding the proper documentation for it. Here is what to do and how:
Call JavaScript Functions from Watir script
win.ToggleProj (‘1‘)
Inject JavaScript to run from Watir script
I used this to alter a JavaScript function on the existing page:
window.CheckReport=function( ) { return true }‘)
As you can see, you can reference the window object and use eval to execute your snippets. The easier way is to add this custom method for easy reference
class Watir::IE; def window; document.parentWindow; end; end


Loading...

No selection was clipped for this page.