<tr><td width="110px"><div class="gwt-Label">Group By:</div></td><td
width="5px"></td><td><span class="gwt-CheckBox foo-check-box"
style="width: 100%;"><input type="checkbox" id="gwt-uid-233"
tabindex="0"><label for="gwt-uid-233"></label></span></td></tr>
I'm trying to click on the checkbox next to the label "Group By".
I'm starting to get the hang of this selenium thing, but still need
some help!
Thanks,
Davina
xpath=//tr[td/div[@class='gwt-Label' and text() = 'Group By']/td/span[@class='gwt-CheckBox']/input[@type='checkbox']
You can probably simplify that a bit, to:
xpath=//tr[td/div/text() = 'Group By']//input[@type='checkbox']
which means "the <input type='checkbox'> contained somewhere within the <tr> that contains <td><div>Group By"
But if the checkbox's id (gwt-uid-233) is repeatable, as these things often are, it would be simpler to use it directly:
id=gwt-uid-233
Ross Patterson
Thanks,
Davina
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.
//label[.='Group By']/preceeding-sibling::input
Regards
Mark
-----Original Message-----
From: seleniu...@googlegroups.com
[mailto:seleniu...@googlegroups.com] On Behalf Of Davina Armstrong
Sent: 07 April 2010 18:25
To: Selenium Users
Subject: [selenium-users] xpath for sibling element
Thanks,
Davina
--
You received this message because you are subscribed to the Google Groups
"Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to
selenium-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/selenium-users?hl=en.
--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
If you have received this email in error please notify postm...@ardescosolutions.com
----- Original Message ----
From: Davina Armstrong <dstar...@gmail.com>
To: Selenium Users <seleniu...@googlegroups.com>
Sent: Wed, April 7, 2010 10:25:09 AM
Subject: [selenium-users] xpath for sibling element
Thanks,
Davina
--
If you have multiple rows,and all are following same pattern like you
have shown in your code
<tr>
<td width="110px">
<div class="gwt-Label">Group By:</div>
</td>
<td width="5px">
</td>
<td>
<span class="gwt-CheckBox foo-check-box" style="width: 100%;">
<input type="checkbox" id="gwt-uid-233" tabindex="0">
<label for="gwt-uid-233">
</label>
</span>
</td>
</tr>
You can use following approach
int count=1;
while(selenium.isElelmentPresent(//tr["+count+"])) //you have to
specify xpath up to row, here I have used only tr
{
if(selenium.isElementPresent(//tr["+count+"]/td/div[text()='Group
By:']))
{
selenium.click((//tr["+count+"]/td[3]/span/input);
break;
}
count++;
}
Let me know If this approach will not work.
Thanks
Ritesh
The code snippet you have supplied will programmatically iterate through
each row in the table until it finds a row that matches the criteria. At
this point iw ill click on the input and break out of the loop.
You could do exactly the same thing with one line of code:
selenium.click("//tr[td/div[.'Group By:']]/td[3]/span/input");
or if you want to check the element is there first:
if (selenium.isElementPresent("//tr[td/div[.'Group
By:']]/td[3]/span/input")){
selenium.click("//tr[td/div[.'Group By:']]/td[3]/span/input");
}
> --
> You received this message because you are subscribed to the Google Groups
> "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to
> selenium-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/selenium-users?hl=en.
>
>