Hi all,

I am new to ruby, and have searched these forums for answers, but have not 
found anything that seems to work or help me. (including links to FAQ's which 
do not appear to be available anymore)

Situation:
I am writing ruby/watir scripts to automate tests against a 
website/application. On one page there are a date field and  a "Search" 
button.after entering wrong dae in date field a popup alert opens and display 
message please enter valid date this dialog box also has a "OK" button.

Problem:
I am unable to gain access to the java alert dialog to gain control of the 
button and click it. The modal dialog have a :title,"Microsofte Internet 
Explorer".but error comes unable to locate with window with title "Microsoft 
Internet Explorer" . So my tests "hang" while it waits for the button to be 
clicked before it can continue on.

I also do not have access to the webcode (java code) to change it, but I know 
that the dialog is simply invoked with 'alert("<text>")'.

Things I have tried (with no success...)
$ie = IE.attach(:title, "Microsoft Internet Explorer")
        $ie.button(:id, '2').click
   
     #
    #require 'win32ole'  # already included if you use 'require watir'
    #
    # Function to look for popups
    #def check_for_popups
      #  autoit = WIN32OLE.new('<nowiki>AutoItX3</nowiki>.Control')
        #
        # Do forever - assumes popups could occur anywhere/anytime in your 
application.
        #loop do
            # Look for window with given title. Give up after 1 second.
          #  ret = autoit.<nowiki>WinWait</nowiki>('Popup Window Title', '', 1)
            #
            # If window found, send appropriate keystroke (e.g. {enter}, {Y}, 
{N}).
            #if (ret==1) then autoit.Send('{enter}') end
            #
            # Take a rest to avoid chewing up cycles and give another thread a 
go.
            # Then resume the loop.
            #sleep(3)
        #end
   # end
    #
    # MAIN APPLICATION CODE
    # Setup popup handler
   # $popup = Thread.new { check_for_popups }  # start popup handler
    #at_exit { Thread.kill($popup) } 
  
  ##$ie.button(:id, 
"ctl00_MainContentPlaceHolder_btn_Search").fire_event("onclick")
      ##   w = WinClicker.new()

        #("#32770", "Microsoft Internet Explorer", 
      
        ##handle = w.getWindowHandle("Microsoft Internet Explorer")
        ##puts handle
   
         ##w.makeWindowActive(handle)
         #w.button(:value,"OK").click
         ##w.clickWindowsButton_hwnd(handle,"OK")
         ##w.close 
  #ie2=IE.attach(:id,"00000fdc")
  #$ie2.enter
  #ie2.button(:name, add.wacTagAdd).getOLEObject.click
  #w = WinClicker.new()
  
  #w.clickWindowsButton("Microsoft Internet Explorer", "OK" , maxWaitTime=2 )
  #w = nil
  #ie2.close 
  #puts "ent 1"
  #$autoit =  WIN32OLE.new('AutoItX3.Control') 
#puts "ent 2"
 # $autoit.WinWait("Microsoft Internet Explorer", "", 0)
#puts "ent 3"
#$autoit.WinActivate("Microsoft Internet Explorer")
#puts "ent 4"
#$autoit.send_keys('enter')
#$autoit.Winbutton(:name,"OK").click
#$autoit.ControlClick("Microsoft Internet Explorer", "", "OK")
#clickWindowsButton("Microsoft Internet Explorer" , "&OK" )
#$autoit.Send("enter")
#puts "ent 5"
 #$autoit.WinWait("Microsoft Internet Explorer", "Look &in", 3) 

 #$autoit.ControlSetText("Microsoft Internet Explorer", "", "", "#{$path}") 

 #$autoit.ControlClick("Microsoft Internet Explorer", "", "&OK")
  #$ie.link(:text, 'New Window').click_no_wait
  #IE.attach_timeout = 1.0
    #ie_new = IE.attach(:title, "Microsoft Internet Explorer")
     #assert(ie_new.text.include?("OK"))
     #ie_new.button(:title,"OK").click
#begin

        #autoit = WIN32OLE.new('AutoItX3.Control')    

                #autoit.ControlClick("Microsoft Internet Explorer",'', '&OK')

                #autoit.ControlClick("Security Information",'', '&OK')

                #autoit.ControlClick("Security Alert",'', '&OK')

                #sleep(1)

#rescue Exception => e

        #puts "error"

#end
       #hwnd = $ie.enabled_popup(5) 
       #puts "hwnd"
#if(hwnd) 

#w = WinClicker.new

  #   w.makeWindowActive(hwnd)
#w.clickJSDialog_NewProcess(button = "OK" )

    
     # puts hwnd.to_s
 #$ie.Window("Microsoft Internet Explorer").button(:title, "OK").click
 #pp=TC_PopUps.new
 #pp.startClicker( "OK" , waitTime = 0.5)
Versions:
ruby 1.8.4
watir 1.5.1.1127
ie 6
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to