Module: CiosHelpers

Defined in:
lib/cios_helpers.rb,
lib/cios_helpers/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Instance Method Details

#multiple_traits(opts = {}) ⇒ Object

Pass an array of query elements. Determines the correct trait for page objects that can have multiple acceptable traits.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cios_helpers.rb', line 30

def multiple_traits opts = {}
  timeout = opts[:timeout] || 10
  traits = opts[:traits] || ["*"]
  trait = ''
  action = lambda do 
    traits.each do |element|
      if element_exists element
        trait = element
        break
      end
    end
    !trait.empty?
  end
  wait_poll until: action, timeout: timeout do ; end
  trait # Return the one trait
end

#once_element_exists(opts = {}) ⇒ Object

Performs a lambda action once the element exists. The default behavior is to touch the specified element.



19
20
21
22
23
24
25
# File 'lib/cios_helpers.rb', line 19

def once_element_exists opts = {}
  raise "No element given." if opts[:element].nil?
  timeout = opts[:timeout] || 10
  action = opts[:action] || lambda { touch opts[:element] }
  wait_for_elements_exist [opts[:element]], timeout: timeout
  action.call
end

#until_element_exists(opts = {}) ⇒ Object

Performs a lambda action until the element appears. The default action is to do nothing.



8
9
10
11
12
13
14
15
# File 'lib/cios_helpers.rb', line 8

def until_element_exists opts = {}
  raise "No element given." if opts[:element].nil?
  timeout = opts[:timeout] || 10
  action = opts[:action] || lambda { ; }
  wait_poll until_exists: opts[:element], timeout: timeout do
    action.call
  end
end