Html code looks like this.
<div>
<span>Title</span>
<input value="a">
</div>
<div>
<span>Price</span>
<input value="">
</div>
I need to check if Span is price then insert value for Price etc...
Basically I can access to all inputs like
for el in driver.find_elements(by=By.XPATH, value="//input"):
try:
if el.parent.span... == 'Price': #HERE I NEED TO ADD MISSING PART
el.send_keys('10')
except:
pass
But then I can't determine upper node value.
Also tried with :
driver.find_element(by=By.XPATH, value="//input/preceding-sibling::span[contains(.,'Price')]")
Like this I'm able to locate Span element but I need to insert price in INPUT.
Since this is only snippet from a way bigger code where class names positions etc. are dynamically generated. I need to go this way.
inputwherespancontains textPriceor this block also must be below the block withTitle?Priceandinputare both inside the div.