I'm trying to verify the text Active: from this example
<div class="details">
<p class="double">
<a href="url">Set as default</a>
<br>
<a id="modal124434" class="modalAction" href="#">Delete</a>
</p>
<span class="bold">TEXT</span>
: 1234567890 (12/2017)
<br>
Active:
<a class="game" href="#GAME">GAME</a>
</div>
I also need to check TEXT to make sure it's there. I used the following to find TEXT:
foo = b.find_element_by_xpath('//span[contains(text(),"TEXT")]/..')
and when I print(foo.text) I can see all the text from the html example abve. So, I thought I could do something like this:
b.find_element_by_xpath('//span[contains(text(),"TEXT")]/..[contains(text(),"Active:")]/a[text()="GAME"]
but I get a NoSuchElement exception. I've also tried:
b.find_element_by_xpath('//*[contains(text(),"Active")]')
and still got nothing. Any help would be much appreciated.
textare you trying to locate exactly? TEXT or Active: or GAME?"Active:"from node or you need to locate element by substrings"TEXT"and"Active:"?text()[2]how can I tell what text is in that element?Active:text, because the<a>that hasGAMEin it will not appear ifActive:isn't present. So I was able to use'//span[contains(.,"TEXT")]/../a[text()="GAME"]'