I have tested my script on version watir 1.5.3, they works very well.I have
modify a little place, it can work on watir 1.6.2 now.
please add require 'watir/ie' line under require 'watir' line.


On Fri, Jan 9, 2009 at 2:07 PM, Wilson Xu <[email protected]>wrote:

> Which watir version do you use?
>
>
> On Fri, Jan 9, 2009 at 1:29 PM, <[email protected]> wrote:
>
>>
>> Hi Wilson,
>> Thanks for the reply. I executed the modified script, but dint work
>> out. I got the following Error:
>>
>> >ruby popup.rb
>> C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.2/lib/watir/waiter.rb:
>> 59:in `wait_until': Timed out after 9.5 seconds.
>> (Watir::Exception::TimeOutException)
>>        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.2/lib/watir/
>> waiter.rb:80:in `wait_until'
>>        from C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/contrib/
>> enabled_popup.rb:10:in `enabled_popup'
>>         from popup.rb:8:in `startClicker'
>>        from popup.rb:27
>> >Exit code: 1
>>
>> Do I need to make any changes in the enabled_popup.rb file?
>>
>>
>> On Jan 9, 6:40 am, "Wilson Xu" <[email protected]> wrote:
>> > you are wrong, Watir can handle javascript pop up box, I have modified
>> your
>> > script, please copy my code to try it. Ha, it works very well.
>> > require 'watir'
>> > require 'watir/contrib/enabled_popup'
>> >
>> > def startClicker( button , waitTime= 9, user_input=nil )
>> >   # get a handle if one exists
>> >   hwnd = $ie.enabled_popup(waitTime)
>> >   if (hwnd)  # yes there is a popup
>> >     w = WinClicker.new
>> >     if ( user_input )
>> >       w.setTextValueForFileNameField( hwnd, "#{user_input}" )
>> >     end
>> >     # I put this in to see the text being input it is not necessary to
>> work
>> >     sleep 3
>> >     # "OK" or whatever the name on the button is
>> >     w.clickWindowsButton_hwnd( hwnd, "#{button}" )
>> >     #
>> >     # this is just cleanup
>> >     w=nil
>> >   end
>> > end
>> >
>> > $ie = Watir::IE.new
>> > $ie.goto('C:/test.html/')
>> > $ie.link(:text, 'Click Here').click_no_wait
>> > startClicker("OK")
>> >
>> > Wilson Xu
>> >
>> > On Thu, Jan 8, 2009 at 6:14 PM, <[email protected]> wrote:
>> >
>> > > Hi Jagdeep,
>> > > I am facing the same problem of handling javascript popups. Inspite of
>> > > repeated posts, dint find any concrete solution. It seems this is a
>> > > limitation with the Watir tool. Pathetic :(
>> >
>> > > On Jan 2, 7:26 pm, Jagdeep Jain <[email protected]> wrote:
>> > > > Hi,
>> > > > I have the following code but the problem here is that I am not able
>> > > > to move forward to next page which appear after clicking on "OK"
>> > > > button of Java Script pop up.
>> > > > HTML is as follows:
>> > > > I save this file in C: drive as test.html
>> >
>> > > > <html> <head> <script type="text/javascript"> function disp_alert()
>> > > > { alert("I am an alert box!!"); } </script> <title> Jagdeep </title>
>> </
>> > > > head>
>> > > > <body> <a href= "http://www.google.com"; onclick="disp_alert()" />
>> > > > Click Here </a>  </body>
>> > > > </html>
>> >
>> > > > Watir Script is as follows:
>> >
>> > > > require 'watir'
>> > > > require 'watir/ie'
>> > > > require 'watir/contrib/enabled_popup'
>> > > > #require 'win32ole'
>> >
>> > > > def startClicker( button , waitTime = 10)
>> > > >   w = WinClicker.new
>> > > >   longName = $ie.dir.gsub("/" , "\\" )
>> > > >   shortName = w.getShortFileName(longName)
>> > > >   c = "start rubyw #{shortName }\\watir\\clickJSDialog.rb#{button} #
>> > > > {waitTime}"
>> > > >   puts "Starting #{c}"
>> > > >   w.winsystem(c)
>> > > >   w=nil
>> > > > end
>> >
>> > > > $ie = Watir::IE.new
>> > > > $ie.goto('C:/test.html/')
>> > > > startClicker("OK")
>> > > > $ie.link(:text, 'Click Here').click_no_wait
>> >
>> > > > Here is the code which does not shows any exception but it is also
>> not
>> > > > moving forward
>> > > > Anyone please help here.
>> >
>> > > > Thanks,
>> > > > Jagdeep
>> >
>> > > > On Jan 1, 3:33 pm, [email protected] wrote:
>> >
>> > > > > Hi Gem,
>> > > > > Thanks for the help. The script which you have posted does not
>> work
>> > > > > for me. Actually it does not call the function  jsClick. Is there
>> > > > > anything which i might be missing? Can i know your Watir version?
>>  I
>> > > > > got the following Error by running your script:>ruby
>> popup_solution.rb
>> >
>> > > > >
>> C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.2/lib/watir/waiter.rb:
>> > > > > 59:in `wait_until': Timed out after 30.499 seconds.
>> > > > > (Watir::Exception::TimeOutException)
>> > > > >         from
>> > > C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.2/lib/watir/
>> > > > > waiter.rb:80:in `wait_until'
>> > > > >         from
>> > > C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir\contrib
>> > > > > \enabled_popup.rb:10:in `enabled_popup'
>> > > > >         from popup_solution.rb:9:in `jsClick'
>> > > > >         from popup_solution.rb:33
>> >
>> > > > > >Exit code: 1
>> >
>> > > > > Regards,
>> > > > > aamittt
>> >
>> > > > > On Jan 1, 11:37 am, gem dandy <[email protected]> wrote:
>> >
>> > > > > > Hello Aami..,
>> >
>> > > > > > I was not able to reach the site - ('http://www.irctc.co.in/').
>> > > > > > However, here is a method that works for me
>> > > > > > at the Google site:
>> >
>> > >
>> ***********************************************************************************************
>> > > > > > require 'test/unit'
>> > > > > > require 'watir/ie'
>> > > > > > require 'win32ole'
>> > > > > > require 'watir\contrib\enabled_popup'
>> >
>> > > > > > def jsClick( a, button, user_input=nil)
>> > > > > >  waitTime=30
>> > > > > >  hwnd = $ie.enabled_popup(waitTime)
>> > > > > >  puts("wait time = 30")
>> > > > > >   if (hwnd)
>> > > > > >   puts("if = hwnd")
>> > > > > >     w = WinClicker.new
>> > > > > >    if ( user_input )
>> > > > > >    puts("if = user input")
>> > > > > >      w.setTextValueForFileNameField(hwnd, "#{user_input}")
>> > > > > >    end
>> > > > > >    sleep 3
>> > > > > >    puts ("CLICK THE BUTTON")
>> >
>> > > > > >     w.clickWindowsButton_hwnd(hwnd, "#{button}")
>> > > > > >     w=nil
>> > > > > >  end
>> > > > > > end
>> >
>> > > > > >    test_site = "http://www.google.com/preferences?hl=en";
>> > > > > >    $ie = Watir::IE.new
>> > > > > >    $ie.goto test_site
>> > > > > >    $ie.maximize()
>> > > > > >    $ie.radio(:id,"slc").set
>> > > > > >     $ie.button(:name,"submit2").click_no_wait
>> > > > > >         sleep 5
>> > > > > >    jsClick( $ie, "OK")
>> >
>> > > > > >    jsClick( $ie, "OK")
>> >
>> > > > > >         # The popup click works when jsClick is called twice,
>> the
>> > > first click
>> > > > > >         # just highlights the popup box. The second click does
>> the
>> > > trick
>> > > > > >         #
>> >
>> > >
>> ***************************************************************************************************
>> >
>> > > > > > Regards,
>> >
>> > > > > > Darryl
>> >
>> > > > > > On Dec 31, 12:21 am, [email protected] wrote:
>> >
>> > > > > > > I am trying to run the below script but getting an error. Can
>> > > anyone
>> > > > > > > help me on this? I want to bypass the javascript popup. Thanks
>> in
>> > > > > > > advance.
>> > > > > > > The script below:
>> > > > > > > require 'watir'
>> > > > > > > include 'watir'
>> > > > > > > #require 'watir/contrib/enabled_popup'
>> > > > > > > require 'test/unit'
>> > > > > > > class TC_recorded < Test::Unit::TestCase
>> > > > > > >         def test_recorded
>> > > > > > >                 ie = Watir::IE.new
>> > > > > > >         ie.goto('http://www.irctc.co.in/')
>> > > > > > >         ie.text_field(:name, 'userName').set('aamittt')
>> > > > > > >         ie.button(:id, 'Button1').click
>> > > > > > >   hwnd = browser.enabled_popup(5)
>> > > > > > > if (hwnd)  #yeah! a popup
>> > > > > > >   popup = WinClicker.new
>> > > > > > >   popup.makeWindowActive(hwnd)
>> > > > > > >   popup.clickWindowsButton("Windows Internet Explorer", "OK",
>> "30")
>> > > > > > > end
>> > > > > > >         end
>> > > > > > > end
>> >
>> > > > > > > Iam getting following error:
>> > > > > > > 1) Error:
>> > > > > > > test_recorded(TC_recorded):
>> > > > > > > NameError: undefined local variable or method `browser' for
>> > > > > > > #<TC_recorded:0x2c7d3e4>
>> > > > > > >     exam1.rb:10:in `test_recorded'
>> >
>> > > > > > On Dec 31 2008, 12:21 am, [email protected] wrote:
>> >
>> > > > > > > I am trying to run the below script but getting an error. Can
>> > > anyone
>> > > > > > > help me on this? I want to bypass the javascript popup. Thanks
>> in
>> > > > > > > advance.
>> > > > > > > The script below:
>> > > > > > > require 'watir'
>> > > > > > > include 'watir'
>> > > > > > > #require 'watir/contrib/enabled_popup'
>> > > > > > > require 'test/unit'
>> > > > > > > class TC_recorded < Test::Unit::TestCase
>> > > > > > >         def test_recorded
>> > > > > > >                 ie = Watir::IE.new
>> > > > > > >         ie.goto('http://www.irctc.co.in/')
>> > > > > > >         ie.text_field(:name, 'userName').set('aamittt')
>> > > > > > >         ie.button(:id, 'Button1').click
>> > > > > > >   hwnd = browser.enabled_popup(5)
>> > > > > > > if (hwnd)  #yeah! a popup
>> > > > > > >   popup = WinClicker.new
>> > > > > > >   popup.makeWindowActive(hwnd)
>> > > > > > >   popup.clickWindowsButton("Windows Internet Explorer", "OK",
>> "30")
>> > > > > > > end
>> > > > > > >         end
>> > > > > > > end
>> >
>> > > > > > > Iam getting following error:
>> > > > > > > 1) Error:
>> > > > > > > test_recorded(TC_recorded):
>> > > > > > > NameError: undefined local variable or method `browser' for
>> > > > > > > #<TC_recorded:0x2c7d3e4>
>> > > > > > >     exam1.rb:10:in `test_recorded'
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to