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 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.
CodePudding user response:
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')]
