Re: [Wtr-general] How do I click the OK button on a java alert?

2007-04-05 Thread shalini
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('nowikiAutoItX3/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.nowikiWinWait/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,0fdc)
  #$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
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Using Until

2007-04-05 Thread Bret Pettichord
Nicola Kennedy wrote:
 I want the code to do the following things:
 1. Check on page for a link.
 2. If link not there, press Next page
   
 3. If link there, click on it.
   
 4. When next page reached (if step 2 followed), repeat the action of looking 
 for link/clicking next.
   
Here is one way:

def click_links ie
  unless ie.link(:url, http://www.freeuk.com;).exists?
ie.link(:value, 'Next page').click
click_links ie
  else
ie.link(:url, http://www.freeuk.com;).click
   end
end

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] IE nested class of module watir?

2007-04-05 Thread Bret Pettichord
aidy lewis wrote:
 I am unsure why IE is a nested class of the module watir
All of the Watir classes are in the Watir module. This is to avoid 
collisions with classes you may be using from other packages. Watir 
tries to be a good citizen.

If you look at other Ruby libraries, you will see that this is a common 
arrangement.

Bret
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] Access all elements in a form

2007-04-05 Thread Sayali Patil

Hi All,
How to access all the elements in a particular form ,in an html document
using watir?
Please let me know.
Thanks,
Sayali
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How do I click the OK button on a java alert?

2007-04-05 Thread Anupama Kaple

Hi
 
Try this piece of code. I found this code on Waitr QA forums and I tried it in 
my suite. It worked
 
def startClicker( OK, waitTime = 3)   w = WinClicker.new   longName = 
$ie.dir.gsub(/ , \\ )   shortName = w.getShortFileName(longName)   c = 
start ruby #{shortName}\\watir\\clickJSDialog.rb #{button} #{waitTime}
puts Starting #{c}   w.winsystem(c)   w=nil end
 
Thanks  Regards,
Anupama Date: Thu, 5 Apr 2007 00:59:09 -0500 From: [EMAIL PROTECTED] To: 
wtr-general@rubyforge.org Subject: Re: [Wtr-general] How do I click the OK 
button on a java alert?  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('nowikiAutoItX3/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.nowikiWinWait/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,0fdc) #$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 Wtr-general@rubyforge.org 
http://rubyforge.org/mailman/listinfo/wtr-general
_
Your friends are close to you. Keep them that way.
http://spaces.live.com/signup.aspx___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] Assign a Selected Value from Drop Down list to any varibale

2007-04-05 Thread vamsi
Hi,

I need to slect one value from the dropdown list and want to store it into one 
varibale.

For selecting value in drop down list: ie.select_list(:id, 
'ctlWorkflow_ddlname').select_value('1')

what is for reading and storing  the same value into one Variable.

Name = ?

As i need to verify the values in other pages.

Thanks in Advance.

Regards

Vamsi
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Assign a Selected Value from Drop Down list to any varibale

2007-04-05 Thread Ravi
names=ie.select_list(:id, 'ctlWorkflow_ddlname').getAllContents #array
name0=ie.select_list(:id, 'ctlWorkflow_ddlname').getAllContents[0] #single item
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Assign a Selected Value from Drop Down list to any varibale

2007-04-05 Thread vamsi
Thank you very much .
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] .getElementsByTagName

2007-04-05 Thread aidy lewis
Are we all using the DOM method .getElementsByTagName to get for example,
a level 2 heading?

return document.getElementsByTagName('h2')

Should we refactor these methods to make a more abstract method

show_labels
show_spans
show_pres
etc?

Thanks

aidy
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] .getElementsByTagName

2007-04-05 Thread Charley Baker

In Watir 1.5 there is support for adding elements fairly easily so that you
shouldn't have to call getElementsByTagName directly. We haven't added
headings yet, but most other common elements are supported and easily
extended, you could put the following in a file and include it in your
scripts:

module Watir

 class H2NonControlElement
   TAG = 'H2'
 end

 class H2s   ElementCollections
   include Watir::CommonCollection
   def element_class; H2; end
 end

module Container

   def h2(how, what)
 return H2.new(self, how, what)
   end

   def h2s
 return H2s.new(self)
   end
end
end

ie.h2s.show

-Charley


On 4/5/07, aidy lewis [EMAIL PROTECTED] wrote:


Are we all using the DOM method .getElementsByTagName to get for example,
a level 2 heading?

return document.getElementsByTagName('h2')

Should we refactor these methods to make a more abstract method

show_labels
show_spans
show_pres
etc?

Thanks

aidy
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Access all elements in a form

2007-04-05 Thread Sayali Patil

Hi Charley,
I can access a single element in the form.
What i want is i should be able to access all the elements in a form with a
loop .
Actually i have nested forms and i m not able to access each element
individually ,so i want to
try n access all the elements and further do the operations .
My scenario si something like this

form

radio button1
form
/form
radio button2
form
/form

now i m able to access the radio button 1 but when i try to access radio
button 2 i get an error
saying cannot find.

Please help me out .


Thanks,
Sayali



On 4/6/07, Charley Baker [EMAIL PROTECTED] wrote:


Something like this:

$ie.form(:name,'myform').button(:value, 'Submit').click

You can take a look at the unittests for watir in form_test.rb, there are
plenty of examples there.

-Charley


 On 4/5/07, Sayali Patil [EMAIL PROTECTED] wrote:

  Hi All,
 How to access all the elements in a particular form ,in an html
 document using watir?
 Please let me know.
 Thanks,
 Sayali

 ___
 Wtr-general mailing list
 Wtr-general@rubyforge.org
 http://rubyforge.org/mailman/listinfo/wtr-general



___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general