Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
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 Empty How do i get the Xpath value for a radio button so i can click the button on a form

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
avatar
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

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

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"/>
avatar
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 Empty Re: How do i get the Xpath value for a radio button so i can click the button on a form

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
avatar
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 Empty Re: How do i get the Xpath value for a radio button so i can click the button on a form

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']
rohit13
rohit13
Master
Master
Posts : 180
Join date : 2012-03-29
Age : 38
Location : INDIA
http://radical-qa.blogspot.in/

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

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

Code:
//input[contains(@id, 'uxRefereeDetails1 ')]
avatar
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 Empty Re: How do i get the Xpath value for a radio button so i can click the button on a form

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

How do i get the Xpath value for a radio button so i can click the button on a form Empty 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