如何使用Ruby获取Watir的href

COD*_*ODA -3 ruby selenium watir

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

屏幕截图:这是我想要抓取的href.

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

任何想法或提示?

pjd*_*pjd 5

你应该能够获得hrefwith 的值

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

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

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