views:

30

answers:

2

Hi,i faced a problem while replaying a script created for yahoomail page.The XPath statement to enter value in the "To" text field , is not working.Following are the XPath statements i used.

At the first try i used

<tr>
 <td>type</td>
 <td>to</td>
 <td>[email protected]</td>
</tr>

Second try was this statement

<tr>
 <td>type</td>
 <td>//div[@id= 'toid']/textarea[@id= 'to'][@name= 'to']</td>
 <td>[email protected]</td>
</tr>

Third try was this

<tr>
 <td>typeKeysAndWait</td>
 <td>//div[@ id= 'composebox']/div[@id= 'toid']/textarea[@id= 'to'][@name= 'to']</td>
 <td>[email protected]</td>
</tr>

The result was like

[error] Element //div[@ id= 'composebox']/div[@id= 'toid']/textarea[@id= 'to'][@name= 'to'] not found

similar result was obtained in the previous attempts. Later when i tried

<tr>
 <td>type</td>
 <td>css=textarea.txtfield</td>
 <td>[email protected]</td>
</tr>

mail id was entered into the text field ,and the script worked perfectly.what might be the reason.Any thoughts.?

I am adding the XPath statements

<div id="composepage">
<div id="composebox" class="roundcorner">
<div id="errorContainer"/>
  <input type="hidden" name="defFromAddress" value="[email protected]"/>
  <div class="fields row">
  </div>
  <div id="toid" class="row">
  <label id="compose_to" for="to">
  </label>
  <textarea id="to" class="txtfield" name="to" autocomplete="off" tabindex="1" style="overflow: hidden; height: 19px;"/>
  </div>
A: 

You have written invalid xpath query.

It should be

//div[@ id='composebox']/div[@id='toid']/textarea[@id='to' and @name='to']

AutomatedTester
Thank you David , it worked.
mgeorge
A: 

The <textarea> has an id attribute, which should be unique, so your first locator of simply to should work. It's possible that the element is not present or visible when your selenium command executes. I would recommend the following:

waitForVisible | id=to | 60000
type | id=to | [email protected]

If your elements have unique ids, and you need to use XPath, you only need to be relative to the closest element with an id attribute.

Dave Hunt
Thank you Dave,The text area got selected , but , no data was typed into it.But the following statement worked.waitForVisible | id=to | 60000 type | //textarea[@id='to'| [email protected]
mgeorge