【发布时间】:2019-07-15 21:08:06
【问题描述】:
下面有这段代码
<div class="gallery-list">
<figure class="figure" ng-class="profileGallery.css" profile-item-remove="9>
<a href="https://#" data-login="" gallery-modal="9" rel="nofollow">
<picture sl-video-preview="https://movie.mp4" sl-safe="" class="ng-isolate-
scope sl-safe">
</a>
</figure>
<figure class="figure hd" ng-class="profileGallery.css" profile-item-
remove="9>
<a href="https://#" data-login="" gallery-modal="9" rel="nofollow">
<picture sl-video-preview="https://movie.mp4" sl-safe="" class="ng-isolate-
scope sl-safe">
</a>
</figure>
<figure class="figure" ng-class="profileGallery.css" profile-item-remove="9>
<a href="https://#" data-login="" gallery-modal="9" rel="nofollow">
<picture sl-video-preview="https://movie.mp4" sl-safe="" class="ng-isolate-
scope sl-safe">
</a>
</figure>
<div>
Xpath
print(WebDriverWait(driver,
20).until(EC.visibility_of_element_located((By.XPATH, "//div[@class='gallery-
list']/figure[@class='figure hd']/a/picture[@class='ng-isolate-scope sl-
safe']"))).get_attribute("sl-video-preview"))
使用此 xpath 代码可以获得一个属性图记录,但这是动态的,有时我有一个、两个、三个、十二个或五十个。 如何通过具有动态列表大小的 xpath sl-video-preview 获取所有出现的属性值。
【问题讨论】:
标签: python-3.x selenium xpath css-selectors webdriverwait