Prev: Modules in Ruby
Next: RbConfig::CONFIG['CPP'] question
From: Mario Ruiz on 14 Jul 2010 12:39 Hi, I'm trying to click a dialog box in Firefox but all the code I found is not working. I have watir and firewatir 1.6.5 Thanks -- Posted via http://www.ruby-forum.com/.
From: Jesús Gabriel y Galán on 20 Jul 2010 07:29 On Wed, Jul 14, 2010 at 6:39 PM, Mario Ruiz <tcblues(a)gmail.com> wrote: > Hi, > I'm trying to click a dialog box in Firefox but all the code I found is > not working. > I have watir and firewatir 1.6.5 Firewatir::Firefox has a method startClicker that does that: $ ri startClicker ---------------------------------------- FireWatir::Firefox#startClicker startClicker(button, waitTime = 1, userInput = nil, text = nil) ------------------------------------------------------------------------ Description: Tells FireWatir to click javascript button in case one comes after performing some action on an element. Matches text of pop up with one if supplied as parameter. If text matches clicks the button else stop script execution until pop up is dismissed by manual intervention. Input: button - JavaScript button to be clicked. Values can be OK or Cancel waitTime - Time to wait for pop up to come. Not used just for compatibility with Watir. userInput - Not used just for compatibility with Watir text - Text that should appear on pop up. What this really does underneath is to change the window.alert method for one that returns what you tell it to. It doesn't really open a window anymore. I've used this successfully once. Hope this helps, Jesus.
From: Mario Ruiz on 13 Aug 2010 07:53 But the thing is... if you click first.. ff keeps waiting and doesn't return the control to ruby so in theory the only way to do it is call startClicker first and then click the button... but it's not working properly since what it is doing is just closing the JS window but not clicking on the button as you can see in this example: require "firewatir" $ff = FireWatir::Firefox.new() #create an object to drive the browser $ff.goto("http://w3schools.com/js/tryit_view.asp?filename=tryjs_confirm") $ff.startClicker( "OK", 4) $ff.button(:value,"Show a confirm box").click sleep 3 $ff.close() -- Posted via http://www.ruby-forum.com/.
From: Jesús Gabriel y Galán on 13 Aug 2010 08:02 On Fri, Aug 13, 2010 at 1:53 PM, Mario Ruiz <tcblues(a)gmail.com> wrote: > > But the thing is... if you click first.. ff keeps waiting and doesn't > return the control to ruby so in theory the only way to do it is call > startClicker first and then click the button... but it's not working > properly since what it is doing is just closing the JS window but not > clicking on the button as you can see in this example: > > require "firewatir" > $ff = FireWatir::Firefox.new() #create an object to drive the browser > $ff.goto("http://w3schools.com/js/tryit_view.asp?filename=tryjs_confirm") > $ff.startClicker( "OK", 4) > $ff.button(:value,"Show a confirm box").click > sleep 3 > $ff.close() I don't know if you have other example that does something in the page when OK is clicked. What startClicker does, is to override the window.alert function with a function that returns OK, so really no popup is open at all. Jesus.
From: Mario Ruiz on 13 Aug 2010 08:07
So there is no way to click the buttons on a javascript window -- Posted via http://www.ruby-forum.com/. |