【问题标题】:How store href from an image xpath selenium ide ui vision katalon recorder如何从图像 xpath selenium ide ui vision katalon 记录器中存储 href
【发布时间】:2020-10-31 02:14:31
【问题描述】:

我想存储图片中的href url,但是当我尝试它时显​​示错误

这是代码

<a href="/mysite.com"><img src="//user/banners/16/08/1614708.gif" alt="AAA" data-tip="BBB" currentitem="false" class="" width="468" height="60"></a>

我想存储 mysite.com

我已经尝试使用 xpath 和 @href 存储属性,但显示错误(仅适用于文本链接)

通常我使用 ui vision 或 katalon recorder,但我暂时找不到好的解决方案。

我只需要 xpath

【问题讨论】:

    标签: selenium xpath katalon


    【解决方案1】:

    试试这个,让父级获得 img src 的标签。

    print(driver.find_element_by_xpath("img[src='//user/banners/16/08/1614708.gif']//parent::a").get_attribute('href'))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2018-11-18
      • 1970-01-01
      • 1970-01-01
      • 2021-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多