I have read numerous posts about problems with Watir and accessing data that is 
computed elsewhere (i.e. in a separate .js file) but unfortunately none of the 
posts have pointed me in the right direction. I am testing a simple html page 
that has no frames but does call javascript functions in an external file. When 
the user has typed text into the text field then a window appears with text in 
it. I would like to access this text to verify it in my Watir test, but all of 
the following return '0' for me:

@@ie.select_list(:id,"sel").getAllContents.length
@@ie.ie.Document.getElementById("sel").options.length
@@ie.selectBox(:index,1).getAllContents.length
@@ie.div(:id,"sid").select_list(:id,"sel").getAllContents.length
@@ie.select_list(:index,1).getAllContents.length

even though @@ie.show_all_objects seems to indicate there is a select list 
(select-multiple)? Does anyone have any suggestions for obtaining this data? 

In advance, thanks very much for any feedback provided!

After executing the following:

@@ie.text_field(:id, "fid").fire_event("onkeyup")
@@ie.text_field(:id, "fid").set("country")
@@ie.button(:value, "Show Synonyms").fire_event("onclick")
@@ie.button(:value, "Show Synonyms").click 

here is the output of @@ie.show_all_objects:

-----------Objects in  page -------------
text/javascript   id=                 src=
text/javascript   id=                 src=js/KMSuggest.js
                  id=
text              name=textField      id=fid              value=country       
alt=                src=
button            name=               id=b                value=Show Synonyms  
alt=                src=
                  name=               id=
select-multiple   name=               id=sel              value=
button            name=               id=                 value=Add           
alt=                src=
button            name=               id=                 value=Clear         
alt=                src=
button            name=               id=                 value=Close         
alt=                src=
button            name=               id=                 value=Add           
alt=                src=
button            name=               id=                 value=Clear         
alt=                src=
button            name=               id=                 value=Close         
alt=                src=
button            name=               id=                 value=Close         
alt=                src=
_______________________________________

Here is a portion of the HTML source:

<body id="bod">
<center>
<h1>This is a test:</h1>
<h4>(Start typing and watch words appear)</h4>
</center>
  <form>
  <center>
    <input id="fid" type="text" size="35" name="textField" value="" 
onkeyup="keyUp(event);">
    &nbsp;
    <input id="b" type="button" value="Show Synonyms" 
onclick="toggleSyns('fid','sid');">
    <br>
   </center>
    <div id="sid" class="synWindow" style="display: none; z-index: 400">
      <center>
      <span class="hintField">(Select options &amp; press Add button)
        &nbsp;&nbsp;&nbsp;<a class="hintField" 
href="javascript:show('hid');hide('sid');">[help]</a></span><br/>
      <select id="sel" multiple size="15">
      </select>
      <input type="button" value="Add" onclick="addSelectedToField();">
      <input type="button" value="Clear" onclick="clearSelected();">
      <input type="button" value="Close" onclick="hide();">
      </center>
    </div>
    <div id="hid" class="helpWindow" style="display: none; z-index: 400">
       <span style="font-weight: bold;">KM-Suggest Help</span><br/>
       <hr/>
       <table class="helpTable" border="0" cellpadding="0" cellspacing="2px">
         <tr>
           <td align="left"><input type="button" value="Add" onclick=""></td>
           <td>Add selected items to text</td>
         </tr>
         <tr>
           <td align="left"><input type="button" value="Clear" onclick=""></td>
           <td>Clear selections in list</td>
         </tr>
         <tr>
           <td align="left"><input type="button" value="Close" onclick=""></td>
           <td>Close the KM-Suggest window</td>
         </tr>
         <tr><td>&nbsp;</td></tr>
         <tr>
           <td colspan="2">To select more than one item, hold down the 
&lt;CNTRL&gt; key while clicking on the items
         </tr>
       </table>
       <hr/>
      <center>
      <input type="button" value="Close" onclick="hide('hid');show('sid');">
      </center>
    </div>
  </form>
</body>
</html>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to