The html below is stored in a selenium WebDriver variable
<td colspan="2" class="pi_mailing_address"><strong>Mailing Address</strong>
<div>
<span class="ng-binding">1236 NW 167 ST </span>
<span ng-show="property.mailingAddress.address2" class="ng-binding ng-hide">STE #</span>
<span ng-show="property.mailingAddress.address3" class="ng-binding ng-hide">789</span>
<span ng-show="property.mailingAddress.city" ng-class="{'inline':property.mailingAddress.city}" class="ng-binding inline">OPA LOCKA,</span>
<span class="inline ng-binding">FL</span>
<span class="inline ng-binding">33055-4314</span>
<span ng-hide="isCountryUSA(property.mailingAddress.country)" class="ng-binding"></span>
</div>
</td>
When I run this
for elem in driver.find_elements_by_xpath('.//span[@class = "ng-binding"]'):
print(elem.text)
I get 7 values.
I want the 4 value which is: 1236 NW 167 ST
How would I use the DOM hierarchy to only extract the address items so I can assign then to a variables.
source https://stackoverflow.com/questions/76657779/finding-a-specific-span-element-with-a-class-using-selenium
Comments
Post a Comment