Lapis Lazuli:Interacting with an element

From Test Automation Wiki
Jump to: navigation, search

After you have selected an element, you can start interacting with it. The element is actually a Watir element, and so it follows the same rules to interact with it.

browser.goto ''

# Selecting the username input field using :objects
elm = browser.find(:input => {:id => 'login-username'})

# Doing stuff with the element

elm.flash # Make the element blink red 3 times # click on it

elm.set 'text' # Write text in the element

elm.send_keys :enter # More info:

elm.hover # Do a hover effect over the element (handy for drop down menus)

# Getting data about the element
=> "login-username"

=> "" # The input field does not contain text

=> "<input id=\"login-username\" class=\"form-control ng-pristine ng-untouched ng-valid\" ng-model=\"\" size=\"60\" placeholder=\"Username\" type=\"text\">"

=> ""

=> "form-group"

Besides the above, there more things you can interact with the browser. If you get stuck with some interaction you want to do, simply search google for "Watir [your question]".