python - 等到 WebElement 属性包含特定值
问题描述
我有所有的图像标签
image_tags = driver.find_elements_by_xpath('//img')
但是,图像的 src 需要一些时间才能更改为“https://....”的格式。所以这就是我现在得到的
for image_tag in image_tags:
WebDriverWait(driver, 60).until(** this image's src contains 'http' **) # how to write this part?
url = image_tag.get_attribute('src') # get the real url address
谢谢!
解决方案
好的,将这个答案[Create custom wait until condition in Python]与@OT413 的答案结合起来,问题解决了
WebDriverWait(self.browser, 60).until(lambda wd: "http" in img_tag.get_attribute('src'))
推荐阅读
- javascript - 如何保护 API 端点,以便只有我们的代码可以使用它们?
- asynchronous - Flutter - 如何从 Firestore 返回当前用户
- julia - 记忆有限视界动态规划
- reactjs - 如何正确实现带有反应路由器的侧边栏?
- tableau-api - 如何获取数据源的 SQL
- tensorflow - 来自 TF.Estimator 的 .pbtxt 的 freeze_graph MemoryError
- javascript - React-native expo 矢量图标未在 android 上显示
- javascript - HighMaps 仅在美国地图中显示最后一个系列的颜色
- python - 如何将 Python 数据框转换为列表列表?
- python - 导入说没有名为“可以”的模块,但库安装在站点包中?