Method: WDA::Debug#source

Defined in:
lib/wda_lib/debug.rb

#source(opts = {}) ⇒ Hash

Get all elements on current screen When accessible is true, ignore all elements except for the main window for accessibility tree When accessible is false, and visible is true, ignore all invisible elements

Parameters:

  • session_id (String)

    , not_fetch_inaccessible [Boolean], not_fetch_invisible [Boolean], timeout [Integer]

Returns:

  • (Hash)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/wda_lib/debug.rb', line 13

def source(opts = {})
  response_type = opts.fetch(:response_type, 'json')
  session_id = opts.fetch(:session_id, nil)
  # not_fetch_inaccessible = opts.fetch(:not_fetch_inaccessible, true)
  # not_fetch_invisible = opts.fetch(:not_fetch_invisible, true)
  timeout = opts.fetch(:timeout, 60)
  @timeout = timeout.to_i if !timeout.nil?
  url = '/source' + '?format=' + response_type
  url = @base_url + '/source' + '?format=' + response_type if session_id.nil?
  begin
    res = get(url, 
              # { accessible: not_fetch_inaccessible, visible: not_fetch_invisible }, 
              @timeout)
  rescue
    raise Error::NoSuchElementError, "Can't fetch current screen elements within #{@timeout}s" if res['status'].nil?
  end
  @timeout = @default_timeout
  res
end