Module: WDA::Debug

Included in:
WDA
Defined in:
lib/wda_lib/debug.rb

Instance Method Summary collapse

Instance Method Details

#find_app(app_name) ⇒ Object

Had issue when there is app shortcut in SIRI search or Today’s extention, having duplication app text, have to find the visibile one



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/wda_lib/debug.rb', line 31

def find_app(app_name)
  max = 1
  app_found = false
  app = nil
  homescreen
  while !app_found && max < 10 do 
    max += 1
    icons(app_name).each do |e| 
      app = e
      if e.displayed?
        app_found = true 
        break
      end
    end
    break if app_found = true
    swipe(@win_x*4/5, 10, @win_y/2, @win_y/2)
  end

  app.nil?? (fail "Can't find app :#{app_name}") : app
    
end

#get_sourceObject



17
18
19
# File 'lib/wda_lib/debug.rb', line 17

def get_source
  get(@base_url + '/source')['value']['tree']['children']
end

#get_window(window_number = 0) ⇒ Object



25
26
27
# File 'lib/wda_lib/debug.rb', line 25

def get_window(window_number = 0)
  get(@base_url + '/source')['value']['tree']['children'][window_number]
end

#get_window_statusbarObject



21
22
23
# File 'lib/wda_lib/debug.rb', line 21

def get_window_statusbar
  get(@base_url + '/source')['value']['tree']['children'][2]
end

#source(session_id = nil, accessible = true, visible = true) ⇒ 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 (String)

    , accessible [Boolean], visible [Boolean]

Returns:

  • (Hash)


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

def source(session_id = nil, accessible = true, visible = true)
  if session_id.nil?
    post(@base_url + '/source', { accessible: accessible, visible: visible })
  else
    post '/source', { accessible: accessible, visible: visible }
  end 
end