Lapis Lazuli:Default values for find / multi find / find all / multi find all and wait options
Revision as of 10:36, 1 June 2017 by Gijsp (talk | contribs) (Gijsp moved page Lapis Lazuli:Default options for find / multi find / find all / multi find all and wait to Lapis Lazuli:Default values for find / multi find / find all / multi find all and wait options without leaving a redirect)
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?, # :present? / :exists? Can we see and interact with it or is it anywhere in the code :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.
On Lapis Lazuli:Selecting an element we go deeper into how to use this in practise.