[wtr-general] Re: Modal dialog window opened from page_load event
Hi Ste, Earlier the wait method would get stuck when there is a popup during page laoding. Now it exits from the waut method and waits for you to handle the popup. Refer to this to handle popups - (doesnt use autoit for this) http://groups.google.com/group/watir-general/browse_thread/thread/c2ee4fdebe00a2d2/d42a15121e820178#d42a15121e820178 Thanks, Tony --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: Modal dialog window opened from page_load event
Hi Tony, I replaced the wait method as you suggested (I had before to update watir: now I have installed ruby 1.8.6 and watir 1.6.2) but I have not succeeded in my goal, yet. After the page loading (for example, after the command ie.goto http:// www.mytargetsite.com) the command ends without any error (without hanging because of the modal popup as before replacing the wait method) but the modal pop up is still there... I put some comment into code in order to follow how it works. The program exits at line 19 of your code, after having correctly identified the windows handler (I checked it with AutoIt) but misspelling the title of the modal popup windows (popwndtitle= -- Finestra di dialogo pagin instead of -- Finestra di dialogo pagina Web. Now I am searching in the site how to send input/message to such a modal popup windows in order to fill a input text box and click on a button on it. If you could give me more help it will be very appreciated. Thanks. Ste --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: Modal dialog window opened from page_load event
Hi, Whenever there is a modal dialog during a page load, the wait method will be stuck till someone clicks on the OK or CANCEL to dismiss the modal dialog. The code will be stuck in the below while loop the wait method(ie- class.rb). begin while @ie.busy # XXX need to add time out sleep a_moment end ie.add_checker PageCheckers ::HANDLE_MODAL would also not work since run_error_checks would only work at the end of the wait method. You would have to make changes to the wait method in C:\ruby\lib\ruby \gems\1.8\gems\watir-1.6.2\lib\watir\ie-class.rb Replace the wait method with the below code - will also handle any security alert, security information, certificate error(ie 6) and return from the wait method when a popup window is loaded when in the busy while loop. http://pastie.org/596458 def wait(no_sleep=false) @rexmlDomobject = nil @down_load_time = 0.0 a_moment = 0.2 # seconds start_load_time = Time.now outval = ' ' * 30 popwndtitle = '' #puts CALLLED WAIT !!! begin while @ie.busy # XXX need to add time out sleep a_moment # 1-SECURITY INFORMATION - PAGE CONTAINS BOTH SECURE AND INSECURE ITEMS YES-6 # 2-Security Alert - Certificate error YES-1 pophwnd = Win32API.new(user32, GetWindow, 'Li', 'L').Call (@ie.hwnd.to_i, 6) # only handle if there is a popup and handle only 2 popups, if any other popups occur return. if pophwnd !=0 Win32API.new(user32, GetWindowText, 'Lpi', 'L').Call (pophwnd,outval,30) popwndtitle = outval.rstrip.chomp(\000) return 0 if !(popwndtitle.include?(Security Alert) || popwndtitle.include?(Security Information)) cntrlhwndYES = Win32API.new(user32, GetDlgItem, 'Li', 'L').Call(pophwnd, 1) Win32API.new(user32, SendMessage,'','L').Call (cntrlhwndYES, 0x0006, 1,0) Win32API.new(user32, SendMessage,'','L').Call (cntrlhwndYES, 0x00F5, 0,0) cntrlhwndYES = Win32API.new(user32, GetDlgItem, 'Li', 'L').Call(pophwnd, 6) Win32API.new(user32, SendMessage,'','L').Call (cntrlhwndYES, 0x0006, 1,0) Win32API.new(user32, SendMessage,'','L').Call (cntrlhwndYES, 0x00F5, 0,0) end end until @ie.readyState == READYSTATE_COMPLETE do sleep a_moment end sleep a_moment until @ie.document do sleep a_moment end documents_to_wait_for = [...@ie.document] rescue WIN32OLERuntimeError # IE window must have been closed @down_load_time = Time.now - start_load_time sleep @pause_after_wait unless no_sleep return @down_load_time end while doc = documents_to_wait_for.shift begin until doc.readyState == complete do sleep a_moment end @url_list doc.location.href unless @url_list.include? (doc.location.href) doc.frames.length.times do |n| begin documents_to_wait_for doc.frames[n.to_s].document rescue WIN32OLERuntimeError, NoMethodError end end rescue WIN32OLERuntimeError end end @down_load_time = Time.now - start_load_time run_error_checks sleep @pause_after_wait unless no_sleep @down_load_time end Let me know if you have any issues. Thanks, Tony --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: Modal dialog window opened from page_load event
Hi Charley, thanks for your reply. I tried the following very simple script: 1 require 'watir' 2 include Watir 3 4 module PageCheckers 5 HANDLE_MODAL = lambda {|ie| ie.modal_dialog.button(:id, 'OK').click} 6 end 7 8 ie = Watir::IE.attach(:title, /TARGET_SITE/) 9 ie.add_checker PageCheckers ::HANDLE_MODAL 10 ie.goto http://www.mytargetsite.com But I got the following errors: ruby HandleModal.rb HandleModal.rb:9: warning: parenthesize argument(s) for future version HandleModal.rb:9: uninitialized constant HANDLE_MODAL (NameError) Any help? Thanks Ste --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: Modal dialog window opened from page_load event
Hi I have also encountered a similar problem, of handling popup during page load and page close events. Is there any solution for the same in watir?? On Tue, Aug 18, 2009 at 2:44 PM, Ste stefano.porcare...@poste.it wrote: Hi, I am not able to handle modal dialog window controls when such a window is opened from the page_load event on the server side code (which launches a script included in the .aspx page). In more detail (I have inspected the code) within the function page_load on the server page (.cs) there is a line of code like this ClientScript.RegisterStartupScript( GetType(), MessaggeRule, OpenPopUpRule('+ mode + ',' + idGrid');, true); then, the javascript function included in the .aspx page OpenPopUpRule () call the method window.showModalDialog(). I think this scenario is not included in the page http://wiki.openqa.org/display/WTR/Pop+Ups. In any case I have tried with send_keys() and Watir.autoit.Send() but I am not still able to access these modal dialog window controls. Thanks in advance for your help Ste --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: Modal dialog window opened from page_load event
Watir has a page checker that allows you to run specific methods on page load. Something along the lines of this: module PageCheckers HANDLE_MODAL = lambda {|ie| ie.modal_dialog.button(:id, 'ok').click} # or whatever, do something with your modal dialog end register the method ie.add_checker PageCheckers ::HANDLE_MODAL Now when you go to a page ie.goto http://www.google.com http://microsoft.com/ This method is called on page load. Charley Baker Lead Developer, Watir, http://wtr.rubyforge.org On Tue, Aug 18, 2009 at 4:36 AM, Pallavi Sharma write2pall...@gmail.comwrote: Hi I have also encountered a similar problem, of handling popup during page load and page close events. Is there any solution for the same in watir?? On Tue, Aug 18, 2009 at 2:44 PM, Ste stefano.porcare...@poste.it wrote: Hi, I am not able to handle modal dialog window controls when such a window is opened from the page_load event on the server side code (which launches a script included in the .aspx page). In more detail (I have inspected the code) within the function page_load on the server page (.cs) there is a line of code like this ClientScript.RegisterStartupScript( GetType(), MessaggeRule, OpenPopUpRule('+ mode + ',' + idGrid');, true); then, the javascript function included in the .aspx page OpenPopUpRule () call the method window.showModalDialog(). I think this scenario is not included in the page http://wiki.openqa.org/display/WTR/Pop+Ups. In any case I have tried with send_keys() and Watir.autoit.Send() but I am not still able to access these modal dialog window controls. Thanks in advance for your help Ste --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---