【发布时间】:2019-06-12 08:26:13
【问题描述】:
我正在尝试从我的 HTML 页面中获取 SCN 的值,该页面采用这种格式 -
<html>
<body>
<div class="hs-customerdata hs-customerdata-pvalues">
<ul>
<li class="hs-attribute">
<map-hs-label-value map-hs-lv-label="ACCOUNTINFO.SCN" map-hs-lv-value="89862530">
<span class="hs-attribute-label" hs-context-data="" translate="" hs-channel="abcd" hs-device="desktop">SCN:</span>
<span ng-bind-html="value | noValue | translate : params" class="hs-attribute-value" context-data="" map-v-key="89862530" map-v-params="" hs-channel="abcd" hs-device="desktop">
89862530</span>
</map-hs-label-value>
</li>
</ul>
</div>
</body>
</html>
到目前为止,我尝试了不同的方法,但无法达到跨度并获取 SCN 值。
我试过了-
scn = self.driver.find_elements_by_xpath(".//span[@class = 'hs-attribute-value']")
这给出了 ElementNotFound 错误。我最接近的是-
div_element = self.driver.find_element_by_xpath('//div[@class="hs-customerdata hs-customerdata-personal"]/ul/li[@class="hs-attribute"]')
然后当我这样做时 -
print(div_element.get_attribute('innerHTML'))
我明白了-
<map-hs-label-value map-hs-lv-label="ACCOUNTINFO.SCN" map-hs-lv-value="{{::customerData.details.scn}}"></map-hs-label-value>
但我无法超越这一点。我是使用 Webdriver 的新手,无法弄清楚这一点。任何帮助将不胜感激。
【问题讨论】:
标签: python selenium-webdriver xpath webdriverwait xpath-1.0