This below will handle yoru javascript/vbscript popups. If they are
native window popups then you have to resort to autoit

require 'watir/ie'
require 'watir/contrib/enabled_popup'

# Main method to click a modal dialog button.
def click_modal_button(ie, type='OK', sleep_time=6, timeout=20)
   hwnd = ie.enabled_popup(sleep_time)
   if (hwnd)
      w = WinClicker.new
      w.clickWindowsButton_hwnd( hwnd, "#{type}")
      w=nil
   end
end

ie=Watir::Browser.new
ie.goto "C:\\test.html"
ie.button(:name, 'cmdClickMe').click_no_wait
click_modal_button(ie)

On Apr 16, 6:37 am, William <s...@grandstream.com> wrote:
> I still can not make it.If you have some good way to handle javascript
> popup menu,please show me,thanks very much!
>
> On Apr 15, 9:54 pm, bwaybandit <lenridge...@gmail.com> wrote:
>
> > a little confusion here.
>
> > 1. when you use click_no_wait, do you see a popup and if you do, your
> > code is not handing it, is that right? (reason i ask is because your
> > initial comment was you could not see the popup?)
>
> > 2. in jsClick, you can remove the second parameter, since it is not
> > being used at all.
>
> > 3. When you are calling jsClick the third parameter does not render in
> > ie or google, so not sure what you are passing in. Should be something
> > like 'OK', 'Cancel'. etc Once you fix that, it should handle your
> > popup
>
> > On Apr 15, 9:33 am, William <s...@grandstream.com> wrote:
>
> > > Here is the method i handle the popup menu,maybe you can give some
> > > advise.
>
> > > def jsClick( ie,a, button, user_input=nil)
> > >   waitTime=30
> > >  hwnd = ie.enabled_popup(waitTime)
> > >  puts hwnd
> > >   if (hwnd)
> > >     w = WinClicker.new
> > >    if ( user_input )
> > >      w.setTextValueForFileNameField(hwnd, "#{user_input}")
> > >    end
> > >    sleep 3
> > >     w.clickWindowsButton_hwnd(hwnd, "#{button}")
> > >     w=nil
> > >  end
> > > end
>
> > > def reboot(ie,unit_url,type)
> > >  ie.maximize()
> > >  ie.goto unit_url
> > >  ie.text_field(:name,"user").set "admin"
> > >  ie.text_field(:name,"pass").set "admin"
> > >  ie.button(:id,"login").click
> > >  case type
> > >  when 2 then
> > >  begin
> > >  ie.link(:url,unit_url+"/cgi-bin/config").click
> > >  end
> > >  when 5 then
> > >  begin
> > >  ie.link(:url,unit_url+"/config_tn.htm").click
> > >  end
> > >  end
> > >  sleep 3
> > >  ie.button(:id,"reboot").click_no_wait
> > >  puts "clicked"
> > >  #ie.button(:id,"reboot").click
> > >  jsClick(ie,@ie, "确定")
> > >  puts "The system("+unit_url+") is going to reboot..."
> > > end
>
> > > On Apr 15, 9:30 pm, William <s...@grandstream.com> wrote:
>
> > > > yes,if I use "click" it would popup,but if i use this method i that it
> > > > can not handle the javascript popup frame in my test.
>
> > > > On Apr 15, 9:01 pm, bwaybandit <lenridge...@gmail.com> wrote:
>
> > > > > Does the popup appear when you use just "click"?
>
> > > > > On Apr 15, 7:14 am, William <s...@grandstream.com> wrote:
>
> > > > > > The html is "<a name="reboot" id="reboot" class="myAreaLink"
> > > > > > onclick="cb_reboot();">
> > > > > >             Reboot</a>"
>
> > > > > > and i use " ie.button(:id,"reboot").click_no_wait" but the popup 
> > > > > > frame
> > > > > > can not come out.- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to