Thx Chuck. Finally I use Autoit to handle it. I just send 'enter' from Autoit to close that dialog. And it works.
On Fri, Dec 23, 2011 at 5:05 AM, Chuck van der Linden <sqa...@gmail.com>wrote: > On Dec 22, 6:26 am, Simson Situmeang <simson.situme...@gmail.com> > wrote: > > Hello Asif, > > > > thx for your reply. > > > > I also tried to use '*$browser.javascript_dialog.button('Leave > Page').click' > > *but It caused error like this: > > *undefined method `javascript_dialog' for #<Watir::Browser:0x20a4848>* > > > > I think that *javascript_dialog only works on Watir*, not in Watir > > Webdriver. > > > > You are correct. Watir and Watir-webdriver have different methods for > dealing with JS dialogs. Examples of both are presented here > http://stackoverflow.com/a/8172888/409820 > > It looks to me as if you are using the command correctly, and using > the correct one. > > The problem in this case is that this may not be a JS confirm popup > but something built in at the browser level (which is still invoked > via JS, but in a very different way from traditional alert/confirm/ > prompt dialogs. You can define a function that gets invoked by > 'window.onbeforeunload' which displays this sort of 'unsaved changes' > message if the user tries to leave the page. (note that fsome > browsers, (recent FF for example) no longer allow the code to define > the message content (because mal sites were using a message to confuse > the user into clicking the wrong button, and thus 'trapping' them on > their site) > > You can read more about how this is done here: > http://www.4guysfromrolla.com/webtech/100604-1.shtml > > The problem is that while I can tell you how this is happening, I'm > not sure offhand how to go about automating a way to click the proper > button in order to continue. RAutomation or Autoit might work, but > only for Windows OS. You could disable it entirely by redefining what > function is called in the event of onbeforeunload, but that may not > meet your testing needs. > > This might be worthy of suggesting that a .leave_page method (that > works similar to the .confirm method) be added to watir-webdriver. > or adding this type of dialog (if possible) to the ones handed by > watir's javascript_dialog_button method. > > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > watir-general@googlegroups.com > http://groups.google.com/group/watir-general > watir-general+unsubscr...@googlegroups.com<http://groups.google.com/group/watir-general%0awatir-general+unsubscr...@googlegroups.com> > -- Simson Partogi Situmeang Informatics - Institut Teknologi Sepuluh Nopember http://simsonsitumeang.wordpress.com/ -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com