Python + Selenium WebDriver - Get div value if sibling contains string -
i trying value div in web page using python/selenium class names repeated contain unique strings, such structure below..
<div class='classname'> <div class="col_num">1 </div> <div class="col_val">5.00 </div> </div> <div class='classname'> <div class="col_num">2 </div> <div class="col_val">2.00 </div> </div>
how value of 'col_val' div contains "col_num = 1"? (the value 5.00 should returned , saved variable)
my current attempt @ solution comes converting selenium ide (code obtained own past question) python below, doesnt work 'contains' not valid in css selector beleive must use xpath not know how.
price = driver.find_element_by_css_selector("div:contains(\"1\")+[class=col_val]").text
following-sibling
axis here:
the
following-sibling
axis indicates nodes have same parent context node , appear after context node in source document.
//div[@class = "col_num" , . = "1 "]/following-sibling::div[@class = "col_val"]
Comments
Post a Comment