Reputation: 595
I have tried different x-paths.
//*[@id='c635_container']
//div[@id='c635_container']
(//div[@class = 'select_container'])[16]
Tried these as well but it selects two paths.
//div[label[contains(text(),'Is there an interpreter or someone else speaking on the behalf of the customer?')]]//div[@class='select-container']
//div[(label[contains(text(),'Is there an interpreter or someone else speaking on the behalf of the customer?')])[1]]
//div[label[contains(text(),'Is there an interpreter or someone else speaking on the behalf of the customer?')] and //input[@class='select2-focusser select2-offscreen']][1]
//div[@class='select-container'] and //label[contains(text(),'Is there an interpreter or someone else speaking on the behalf of the customer?')] and //input[@class='select2-focusser select2-offscreen']]
//div[label[contains(text(),'Is there an interpreter or someone else speaking on the behalf of the customer?')]]
This
//div[@class = ‘select_container’]
is common XPath for all dropdowns and ids are dynamic. So, Need to figure it out another way.
Please check the link:-
https://drive.google.com/file/d/1a96K2Zo7wOTZIHdBXLo_z-2WSO3T0b2R/view?usp=sharing
//div//label[text()='Is there an interpreter or someone else speaking on the behalf of the customer?'] and //div[@class='select-container']
This also does not work.
Upvotes: 1
Views: 80
Reputation: 595
Answer is here
//h1[text()=‘Interpreter’]/following-sibling::div//a[@class=‘select2-choice’]
Upvotes: 1
Reputation: 1836
Try below code - It was hand-written so if there is any spelling error please correct it.
//label[contains(text(),'Is there an interpreter or someone else speaking on the behalf')]/following-sibling::div[@class='select-container']/div[@class='select2-container']/input
Note - Change the destination element as per your need. Here i have used /input
Upvotes: 0
Reputation: 176
Try find some unique for needed control. E.g. Only the needed div contains labels, or only the needed div is child of span with some unique class, etc. I can suggest the next XPath:
//div[label[contains(text(), '<part of the text above the dropdown>')]]/div[@class = ‘select_container’]
Upvotes: 1