Share
Go down
Pilot_Riaz
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-08-24

How do i get the Xpath value for a radio button so i can click the button on a form

on Mon May 21, 2012 5:42 pm
Hi,

There are some radio buttons on a form. The HTML code for it is below. I am writing the selenium in C# Visual Studio. I want to click this button,
to do this i need to use xpath so it can click the right button.

I would need xpath to find the value 84632 out of the code shown below (type=radio). I can then store 84632 into a variable (id13)
and then use selenium.click as follows:


selenium.Click("id=ctl00_uxFormTemplate_uxApplicationControl_uxRefereeContainer_uxRefereeDetails1_uxQuestionControl1_" + id13 + "_7_RBL_0"


input id = "ctl00_uxFormTemplate_uxApplicationControl_uxRefereeContainer_uxRefereeDetails1_uxQuestionControl1_26682_7_26682_7_RBL_0" type="radio" value="84632" name="ctl00$uxFormTemplate$uxApplicationControl$uxRefereeContainer$uxRefereeDetails1$uxQuestionControl1$26682_7$26682_7_RBL"/>

label for = "ctl00_uxFormTemplate_uxApplicationControl_uxRefereeContainer_uxRefereeDetails1_uxQuestionControl1_26682_7_26682_7_RBL_0">Yes
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Re: How do i get the Xpath value for a radio button so i can click the button on a form

on Mon May 21, 2012 6:00 pm
Is there any part of id which remains uniquely constant in this html ? -

Code:
input id = "ctl00_uxFormTemplate_uxApplicationControl_uxRefereeContainer_uxRefereeDetails1_uxQuestionControl1_26682_7_26682_7_RBL_0" type="radio" value="84632" name="ctl00$uxFormTemplate$uxApplicationControl$uxRefereeContainer$uxRefereeDetails1$uxQuestionControl1$26682_7$26682_7_RBL"/>

_________________
Thanks
Tarun K
Free Selenium Training
Pilot_Riaz
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-08-24

Re: How do i get the Xpath value for a radio button so i can click the button on a form

on Mon May 21, 2012 6:46 pm
tarun3kumar wrote:Is there any part of id which remains uniquely constant in this html ? -

Code:
input id = "ctl00_uxFormTemplate_uxApplicationControl_uxRefereeContainer_uxRefereeDetails1_uxQuestionControl1_26682_7_26682_7_RBL_0" type="radio" value="84632" name="ctl00$uxFormTemplate$uxApplicationControl$uxRefereeContainer$uxRefereeDetails1$uxQuestionControl1$26682_7$26682_7_RBL"/>

Yes the variable uxRefereeDetails1 remains unique.

The next radio button on the form is uxRefereeDetails2, uxRefereeDetails3
Pilot_Riaz
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-08-24

Re: How do i get the Xpath value for a radio button so i can click the button on a form

on Tue May 22, 2012 5:43 pm
I have tried this Xpath (below) but it finds all of the radio buttons. If i can include to search for the 'Yes' keword then it will find the 1 radio button which i need. Yes is a label type

//tr[descendant[contains(@for,'uxRefereeDetails1')]]//input[@type='radio']
avatar
rohit13
Master
Master
Posts : 180
Join date : 2012-03-29
Age : 31
Location : INDIA
http://radical-qa.blogspot.in/

Re: How do i get the Xpath value for a radio button so i can click the button on a form

on Tue May 22, 2012 5:53 pm
As uxRefereeDetails1 in ID will remain unique, you can use

Code:
//input[contains(@id, 'uxRefereeDetails1 ')]

_________________
Radical QA
http://radical-qa.blogspot.in/
Pilot_Riaz
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-08-24

Re: How do i get the Xpath value for a radio button so i can click the button on a form

on Tue May 22, 2012 8:38 pm
rohit13 wrote:As uxRefereeDetails1 in ID will remain unique, you can use

Code:
//input[contains(@id, 'uxRefereeDetails1 ')]

Thanks, just tried your code above. It is highlighting the First Name text field. Looks like uxRefereeDetails1 is not unique.

I have noticed the value variable value=84632 is unique. I should be able to use this variable as it's value is different for every radio button question
Sponsored content

Re: How do i get the Xpath value for a radio button so i can click the button on a form

Back to top
Permissions in this forum:
You cannot reply to topics in this forum