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 Try to find app on current screen, if can’t find, click home button to get first page of springboard



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/wda_lib/debug.rb', line 36

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

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

#get_sourceObject



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

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

#get_window(window_number = 0) ⇒ Object



29
30
31
# File 'lib/wda_lib/debug.rb', line 29

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

#get_window_statusbarObject



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

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_id (String) (defaults to: nil)

    , accessible [Boolean], visible [Boolean]

Returns:

  • (Hash)


13
14
15
16
17
18
19
# File 'lib/wda_lib/debug.rb', line 13

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