Tricky checkbox selection

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Tricky checkbox selection

Paatsch, Bernd
Tricky checkbox selection

Hello,

I have written following code

<tr>
        <td>click</td>
        <td>//input[@type="checkbox"]
        <td></td>
</tr>

However it does not select the checkbox. The difficulty is that the value for the checkbox is generated by a database in the background responding to a search request. So I can not use

        <td>//input[@type="checkbox" and value="25"]

Is there any other way to make it work? (I am playing with the xpath of the table. Is tr[0] there first table row or tr[1]? Until now I had no luck to get it to work.)





<p><table class="table">
 <tr class="table_header">
  <th></th>
  <th>Name</th>
  <th>Type</th>
  <th>Extension</th>            
 </tr>

<tr><td><input  type="checkbox" name="Add_member[]" value="25"></td><td> Paatsch</td><td> Subscriber</td><td>208</td></tr>
</table></p>

Thanks
***************************************
Bernd Paatsch


Reply | Threaded
Open this post in threaded view
|

Re: Tricky checkbox selection

Alexandre Garel
Paatsch, Bernd a écrit :
Tricky checkbox selection

Hello,

I have written following code

<tr>
        <td>click</td>
        <td>//input[@type="checkbox"]
        <td></td>
</tr>

However it does not select the checkbox. The difficulty is that the value for the checkbox is generated by a database in the background responding to a search request. So I can not use

        <td>//input[@type="checkbox" and value="25"]

Is there any other way to make it work? (I am playing with the xpath of the table. Is tr[0] there first table row or tr[1]? Until now I had no luck to get it to work.)





<p><table class="table">
 <tr class="table_header">
  <th></th>
  <th>Name</th>
  <th>Type</th>
  <th>Extension</th>            
 </tr>

<tr><td><input  type="checkbox" name="Add_member[]" value="25"></td><td> Paatsch</td><td> Subscriber</td><td>208</td></tr>
</table></p>

Why don't you use the locator name=Add_member[] ?
Otherwise, if the xpath element does not work it may be because there is another input in the page. What about //input[@type="checkbox"][1] (first checkbox in the document, see http://www.zvon.org/xxl/XPathTutorial/General/examples.html)

Hope it helps
Alex




Reply | Threaded
Open this post in threaded view
|

RE: Tricky checkbox selection

Paatsch, Bernd
In reply to this post by Paatsch, Bernd
My mistake! I tried to click the checkbox in the wrong window. I had following code:
<tr>
    <td>selectWindow</td>
    <td>null</td>
    <td></td>
</tr>
<tr>
        <td>click</td> 
        <td>//input[@name='Add_member[]']</td>
        <td></td>
</tr>
 
And of course it can't work since the checkbox is in the popup window and not the main window.
 
--Bernd


From: Alexandre Garel [mailto:[hidden email]]
Sent: Friday, January 13, 2006 1:02 AM
To: [hidden email]
Subject: Re: [selenium-users] Tricky checkbox selection

Paatsch, Bernd a √©crit :

Hello,

I have written following code

<tr>
        <td>click</td>
        <td>//input[@type="checkbox"]
        <td></td>
</tr>

However it does not select the checkbox. The difficulty is that the value for the checkbox is generated by a database in the background responding to a search request. So I can not use

        <td>//input[@type="checkbox" and value="25"]

Is there any other way to make it work? (I am playing with the xpath of the table. Is tr[0] there first table row or tr[1]? Until now I had no luck to get it to work.)





<p><table class="table">
 <tr class="table_header">
  <th></th>
  <th>Name</th>
  <th>Type</th>
  <th>Extension</th>            
 </tr>

<tr><td><input  type="checkbox" name="Add_member[]" value="25"></td><td> Paatsch</td><td> Subscriber</td><td>208</td></tr>
</table></p>

Why don't you use the locator name=Add_member[] ?
Otherwise, if the xpath element does not work it may be because there is another input in the page. What about //input[@type="checkbox"][1] (first checkbox in the document, see http://www.zvon.org/xxl/XPathTutorial/General/examples.html)

Hope it helps
Alex