Method: WDA::FindElement#find

Defined in:
lib/wda_lib/find_element.rb

#find(type, value) ⇒ Hash

Find element with given type and value, return first found element



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/wda_lib/find_element.rb', line 12

def find(type, value)
  wait = Wait.new(:timeout => @timeout) # seconds

  begin
    wait.until {
      @element = post('/element', { using: stringlize(type), value: value }) 
      @element['status'] == 0
    }
  ensure
    raise Error::NoSuchElementError, "Can't find '#{value}' with type '#{type}'" if @element['status'] != 0 
  end

  Element.new self, @element['value']
end