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
-~----------~----~----~----~------~----~------~--~---