[Wtr-general] Asking two questions related on javascript pop upwindow

Cain, Mark Mark_Cain at rl.gov
Thu Apr 13 10:47:13 EDT 2006


You need to have defined the startClicker() method somewhere in your script.  It is mostly reliable.

 

Do something like this:

 

require 'watir/WindowHelper'
require 'watir'
require 'toolkit/onc_login'
require 'toolkit/onc_logout'
require 'toolkit/javascriptHd'

 

# Add this method to your script

def startClicker( button , 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

 

login

$ie.link(:text, "Search for Protocol").click

$ie.textField(:id, "str").set("J0260")

$ie.button(:name, "search").click

listTable = $ie.table(:id, "enroll_list")

# here, there are some hidden field, maybe that's why the number of rows is 22
$ie.checkbox(:index, 5).set
$ie.button(:value, "Consent").click

 

startClicker("OK", 3)
$ie.button("Submit").click

 

Hope this helps,

 

--Mark

 

________________________________

From: wtr-general-bounces at rubyforge.org [mailto:wtr-general-bounces at rubyforge.org] On Behalf Of gege qian
Sent: Thursday, April 13, 2006 7:27 AM
To: wtr-general at rubyforge.org
Subject: [Wtr-general] Asking two questions related on javascript pop upwindow

 

Hi Paul   

 

I'm new to watir and ruby. I have two questions to ask

1) i read the post on http://rubyforge.org/pipermail/wtr-general/2005-April/001427.html. I tried the way paul suggested, but never succeed.

 

here is the code

 

require 'watir/WindowHelper'
require 'watir'
require 'toolkit/onc_login'
require 'toolkit/onc_logout'
require 'toolkit/javascriptHd'

login

$ie.link(:text, "Search for Protocol").click

$ie.textField(:id, "str").set("J0260")

$ie.button(:name, "search").click

listTable = $ie.table(:id, "enroll_list")

# here, there are some hidden field, maybe that's why the number of rows is 22
$ie.checkbox(:index, 5).set
$ie.button(:value, "Consent").click

startClicker("OK", 3)
$ie.button("Submit").click


helper = WindowHelper.new
helper.push_confirm_button_ok()

The button on the pop up window was never clicked

would you mind giving me some feedback on this

 

2)
In our application , we have a calendar image, which user can click on for selecting
the date. I do not know if there is a way to a)pop up the calendar, b)and select the date.
the html source code is as follows:
<table class="header_info"><tr valign="top"><td ><label>  *Date consented</label><br />
<input class="date" id="consents_530" name="consents[530][date_consent_signed]" size=12 type="text" />
<br />
</td>
<td ><br />
<img alt=Calendar class=date id=consents_530_b src=/images/calendar.png title="Show calendar"/>
<script type="text/javascript">
Calendar.setup({ inputField:"consents_530", button:"consents_530_b", cache:true, ifFormat:"%m/%d/%Y", firstDay:0, range:[1956,2008], showOthers:true, step:1 })
</script>
</td>
</tr>
</table>

 

Thanks a lot

gege

________________________________

Blab-away for as little as 1¢/min. Make PC-to-Phone Calls <http://us.rd.yahoo.com/mail_us/taglines/postman2/*http:/us.rd.yahoo.com/evt=39663/*http:/voice.yahoo.com>  using Yahoo! Messenger with Voice.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060413/d92d9dc8/attachment.html 


More information about the Wtr-general mailing list