【问题标题】:How to get href with Watir using Ruby如何使用 Ruby 通过 Watir 获取 href
【发布时间】:2017-02-19 07:14:43
【问题描述】:

我正在尝试使用 Watir 来抓取页面上的特定链接:

Screenshot: Here is the href I am trying to grab.

我的猜测是我需要指定祖先元素 biz-website(?) 然后向下遍历到 a 标记并以某种方式获取它的 href,但我不确定我的代码的语法需要什么要做到这一点。

有什么想法或提示吗?

【问题讨论】:

标签: ruby selenium watir


【解决方案1】:

你应该可以得到href的值

browser.span(:class, 'biz-website').a.href

如果'biz-website' 类对于您页面上的跨度不是唯一的,您也可以使用'biz-website js-add-url-tagging'。如果这仍然不是唯一的,您也可以尝试

browser.span(:text, 'Business website').parent.a.href

【讨论】:

  • 很高兴为您提供帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-04-16
  • 2021-05-04
  • 2015-10-22
  • 1970-01-01
  • 1970-01-01
  • 2011-03-07
  • 1970-01-01
相关资源
最近更新 更多