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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -