I've got a field with a date in it that's identified by a code that's shown in the div previous to it.
<div class="fcode"> <div class="fcode_n">(123)</div> <div class="fcodeText">Date</div> </div> <div class="text">09.01.2020</div>
All the class names are generic and appear many times, but I can find the div class containing the code I'm after (123) by using
element = browser.find_element_by_xpath("//div[contains(text(),'151')]")
and can find the parent using
parent = element.find_element_by_xpath("..")
But I'm not stuck on how to find the date in the next element (which is what I'm after). The next element is , I suppose, the following sibling of the parent. There is a 'following_sibling' method like that gets you the sibling of something in your xpath, like this:
but that of course gets me the fcodeText element, not what I'm after - I blv. I need something in the form of
since I'm searching based on an element and not searching the whole document for the sibling following a given bit of text. I don't seem to find any docs on the use of ".." for finding a parent, but if I could it might have info on an analogous method for sibling instead of parent.