First time here? Check out the site's "greatest hits" or read a post from the archives. Feel free to leave a comment or ask a question, and consider subscribing to the latest posts via RSS or e-mail. Thanks for visiting!
« Feed Auto Discovery | Main | NUnit/Watir/Ruby Test Integration »

Clicking a JavaScript Dialog using Watir

Posted in Ruby | Watir | Javascript.

There will soon be an easy way to click and generally deal with JavaScript Dialogs with Watir (Web Application Testing in Ruby, pronounced "WATER"). It's always been possible, but the team is working on ways to make it easier. Until that day comes, we use the old way. Mark Cain posted sample code recently on the Wtr-General Mailing List. I'd been meaning to post my code that fires up another Ruby "thread," but his is arguably simpler if not slightly brute force. Thanks Mark!

#Put this method in your script:

def startClicker( button , waitTime = 3)
   w = WinClicker.new
   longName = $ie.dir.gsub("/" , "\\" )
   shortName = w.getShortFileName(longName)
   c = "start ruby #{shortName}\\watir\\clickJSDialog.rb #{button}
#{waitTime} "
   puts "Starting #{c}"
   w.winsystem(c)
   w=nil
 end

#Then call it right before you click the button (or whatever) that
causes the javascript popup to display:

startClicker("OK" , 3)
$ie.button("Submit").click

Tracked by:
"Scott rocks" (Keyvan Nayyeri) [Trackback]


Friday, January 13, 2006 5:48:09 PM (Pacific Standard Time, UTC-08:00)
I thought I read somewhere that they had deprecated WinClicker. I thought the preferred method was something along the lines of:

Thread.new { sleep 0.1; WindowHelper.new.push_security_alert_yes }

I kinda prefer the way Selenium handles it. It just has a simple "verifyAlert" command. I'm not real sure on the details of how it works (never really looked), but I think it actually supresses the execution of alert().
Thursday, January 19, 2006 11:41:36 AM (Pacific Standard Time, UTC-08:00)
Is there any way of handling a Javascript Popup Window with a select drop-down listing?
Thanks in advance.
Comments are closed.

Contact

Sponsors

Hosting By

On this page...

Tags

Calendar

<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

Archives

Google Ads