Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

» Selenium IDE Verify different Maps (Hybridview, Mapview etc.)
Fri Nov 25, 2016 9:56 pm by DJ87

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

View previous topic View next topic Go down

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

Post by Pilot_Riaz 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

Pilot_Riaz
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-08-24

Back to top Go down

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

Post by tarun3kumar 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

tarun3kumar
Master
Master

Posts : 186
Join date : 2012-02-14

http://seleniumtests.com

Back to top Go down

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

Post by Pilot_Riaz 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

Back to top Go down

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

Post by Pilot_Riaz 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']

Pilot_Riaz
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-08-24

Back to top Go down

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

Post by rohit13 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/

rohit13
Master
Master

Posts : 180
Join date : 2012-03-29
Age : 30
Location : INDIA

http://radical-qa.blogspot.in/

Back to top Go down

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

Post by Pilot_Riaz 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

Pilot_Riaz
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-08-24

Back to top Go down

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

Post by Sponsored content Today at 1:13 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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