Link Elements  

Overview

Watir::Anchor

It is accessed by calling either Browser#a or Browser#link. Creating an AnchorCollection is accomplished with either Browser#as or Browser#links. For all of the different ways of locating an Anchor element, take a look at our Locating Elements Guide.

They also inherit methods from standard Web Elements

Common or Special Methods

Standard Setter Interface

This functionality was added in Watir 7 beta 2.

Anchor#set is the same behavior as the superclass Element; if no arguments are passed or true is passed, it will click the link.

Example

browser = Watir::Browser.start 'watir.com'

link = browser.link(href: /guides/)
link.href == 'http://watir.com/guides/' # => true
link.click

browser.close

Last Updated: March 28, 2021