Clicking on Checkboxes under Table.

1,117 views
Skip to first unread message

Bhavesh

unread,
Mar 6, 2012, 5:31:45 PM3/6/12
to Selenium Users
Hi,

I have a table like this :

CKHBOX RevName RevEmail
checkbox usera us...@a.com
checkbox userb us...@b.com


Now i want to click on checkbox [Which is a real checkbox] where
RevName is userb.

I want to do this in Selenium, we are using JAVA.

Can someone tell me how to write code such that i can click checkbox
as above.

Any help is appreciated.

Bhavesh

Moises Siles

unread,
Mar 6, 2012, 5:43:56 PM3/6/12
to seleniu...@googlegroups.com
Hi 

What is your selenium version? and could you share your code to see what you have done so far

Regards


Bhavesh

--
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.


Bhavesh

unread,
Mar 6, 2012, 5:51:50 PM3/6/12
to Selenium Users
We are using Selenium webdriver.

I have not written any code till now.

Im very new and looking for some stuff or code if it si there for this
table.

Bhavesh

CKP

unread,
Mar 9, 2012, 6:10:23 AM3/9/12
to Selenium Users
Hi,

It is possible to check the particular check box using xpath. First
select the second row using the "userb" and then click on
corresponding check box in that row.

For e.x: xpath: //tr[td/div/@id='oj']//
div[@class='auh']
Selenium command: selenium.click("//tr[td/div/
@id='oj']//div[@class='auh']");

In the above example, I first selected the second row ( //tr[td/div/
@id='oj'] ) and then selected the corresponding 'div' component or
'check box' from that particular row (//tr[td/div/@id='oj']//
div[@class='auh'] ).

Try and let me know.

Regards,
Koushikk Prabhu.

Shaba K

unread,
Mar 9, 2012, 6:23:12 AM3/9/12
to seleniu...@googlegroups.com

@Koushik
He is using WebDriver

so <driverObject>.findelementBy.xpath("<put your xpath here>");

-Shabana

Yeshwant Murali

unread,
Mar 9, 2012, 6:52:34 AM3/9/12
to seleniu...@googlegroups.com
My thoughts to more generic approach...
1. Get the table name
2. Get the row count
3. Since you know the column name of the email id, capture that and I am sure..it would increment by number, so make the object identifier generic
4. Compare the email id that you want to identify with the cell value
5. If found, click on the check box ( this again would increment by number )
6. To do all this put it in a 'For' loop from Step 3 (after you get row count)
7. Pass the email id as a parameter, so that it can be used to compare with the cell value
 
Hope this helps.
Thank you,
Yeshwant

jeevan

unread,
Mar 9, 2012, 7:23:15 AM3/9/12
to seleniu...@googlegroups.com
You can do this by directly giving the value of the checkbox..


//input[@value='userb']
You can change the value to name in case it is unique.
Thanks,
Jeevan
Reply all
Reply to author
Forward
0 new messages