Difference between revisions of "Lapis Lazuli:Interacting with an element"
(Created page with "After you have selected an element, you can start interacting with it. The element is actually a [http://watir.github.io/ Watir] element,...") |
|||
Line 15: | Line 15: | ||
elm.set 'text' # Write text in the element | elm.set 'text' # Write text in the element | ||
− | elm.send_keys :enter # More info: | + | elm.send_keys :enter # More info: http://watir.com/guides/special-keys/ |
elm.hover # Do a hover effect over the element (handy for drop down menus) | elm.hover # Do a hover effect over the element (handy for drop down menus) |
Latest revision as of 17:56, 8 March 2021
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 'http://training-page.testautomation.info/' # 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 elm.click # click on it elm.set 'text' # Write text in the element elm.send_keys :enter # More info: http://watir.com/guides/special-keys/ elm.hover # Do a hover effect over the element (handy for drop down menus) # Getting data about the element elm.id => "login-username" elm.text => "" # The input field does not contain text elm.html => "<input id=\"login-username\" class=\"form-control ng-pristine ng-untouched ng-valid\" ng-model=\"Users.login_data.name\" size=\"60\" placeholder=\"Username\" type=\"text\">" elm.attribute_value('ng-model') => "Users.login_data.name" elm.parent.class_name => "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]".