Reputation: 11
I have been stuck in a problem , I am trying to render elements that contains a certain class , I was successful at that but the problem is they are located in a modal that pops up when I click a certain button. Now, when I use this line of code
which_groups = browser.find_elements_by_xpath("//div[contains(@class,'<that class name>')]")
I render other elements also on that page and I have to use list indices to locate desired elements. What I noticed in the html is the element contains this unique html code.
<div class="oajrlxb2 gs1a9yip g5ia77u1 mtkw9kbi tlpljxtp qensuy8j
ppp5ayq2 goun2846 ccm00jje s44p3ltw mk2mc5f4 rt8b4zig n8ej3o3l
agehan2d sk4xxmp2 rq0escxv nhd2j8a9 mg4g778l pfnyh3mw p7hjln8o
kvgmc6g5 cxmmr5t8 oygrvhab hcukyx3x tgvbjcpo hpfvmrgz jb3vyjys
rz4wbd8a qt6c0cv9 a8nywdso l9j0dhe7 i1ao9s8h esuyzwwr f1sip0of
du4w35lb btwxx1t3 abiwlrkh p8dawk7l lzcic4wl ue3kfks5 pw54ja7n
uo3d90p7 l82x9zwi a8c37x1j" role="button" tabindex="0">
Is there any chance that I can use two xpaths like one that I used above and
//*[@role="button"]
I thought of this idea , may be I am wrong but please, can any one suggest any idea how can I locate these elements.
Thank You.
Upvotes: 0
Views: 1621
Reputation: 2571
To find a div of a certain class that contains a span at any depth containing certain text, try:
//div[contains(@class, 'measure-tab') and contains(.//span, 'someText')]
Upvotes: 3