Difference between revisions of "Lapis Lazuli:Default values for find / multi find / find all / multi find all and wait options"
m (Gijsp moved page Lapis Lazuli:Selecting an element to Lapis Lazuli:Default options for find / multi find / find all / multi find all and wait without leaving a redirect) |
|
(No difference)
|
Revision as of 15:44, 31 May 2017
Lapis Lazuli is a tool to helps you select an element easier than Watir and it also applies best practises. On this page it is explained how to select an element in multiple ways.
Defaults
The default options for a find action:
# find defaults, returns 1 element browser.find( :element => {:attribute => :value}, # E.G. :input => {:name => 'username'} :filter_by => :present?, # Only look for elements that are present :context => a_different_element, # Optionally add a context element to search within :pick => :first, # pick the :first / :last / :random / [int] of the found elements :throw => true, # When false, no error will be thrown if the element can't be found :message => nil, # When nil a default error will be thrown, else you can add a string for a custom error message ) # find_all defaults, returns an array of elements browser.find_all( # All the options are the same, except: :pick => nil, # When :pick is nil, all found elements will be returned in an array ) # multi_find defaults, returns 1 element that matches ANY of the selectors browser.multi_find( :selectors => [# A list of different element selectors { :element => {:attribute => 'value'}, # E.G. :input => {:name => 'username'} :filter_by => :present?, # Only look for elements that are present :context => a_different_element # Optionally add a context element to search within }, { :anotherElement => {:attribute => 'differentValue'}, # E.G. :input => {:name => 'username'} :filter_by => :present?, # Only look for elements that are present :context => a_different_element # Optionally add a context element to search within } ], :mode => :match_any, # :match_one / :match_any / :match_all of the given selectors # The rest of the options are the same as browser.find ) # multi_find_all, returns all the elements that match any of the selectors browser.multi_find_all( :selectors => [# A list of different element selectors # The same as with browser.multi_find ], :mode => :match_any, # :match_one / :match_any / :match_all of the given selectors :pick => nil, # When :pick is nil, all found elements will be returned in an array # The rest of the options are the same as browser.find ) # wait, waits 10 seconds for the selectors to return a value and else throws an error browser.wait( # All the options are the same as browser.find :timeout => 10, # [int] in seconds to wait for the element to appear :condition => :until # wait :until or :while an element is present ) # wait_all. multi_wait & multi_wait_all are the same as their find relatives, but than with the wait options.