CODA CODA - 10 days ago 4x
Ruby Question

How to Get href with Watir (Ruby)

What I'm trying to do: Use Watir to grab a specific link on a page

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

The struggle: My guess is I need to specify the ancestor element

? then traverse down to the
tag and grab it's
somehow, but I'm not sure what the syntax of my code would need to be do that.

Any ideas or tips?

pjd pjd

You should be able to get the value of the href with

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

If the class 'biz-website' is not unique for spans on your page, you can also use 'biz-website js-add-url-tagging'. If that is still not unique, you could also try

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