Module: Mobile::Appium::Server

Includes:
OS
Defined in:
lib/mobmanager/mobile/appium/server/server.rb

Instance Method Summary collapse

Methods included from OS

#mac?

Instance Method Details

#end_appium_serverObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mobmanager/mobile/appium/server/server.rb', line 36

def end_appium_server
  if node_running?
    puts 'Terminating Appium server...'
    if mac?
      termination = system 'pkill node'
    else
      termination = system 'TASKKILL /F /IM node.exe'
    end
    return print_response(termination)
  end
  puts 'No Appium server found.'
end

#node_running?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
# File 'lib/mobmanager/mobile/appium/server/server.rb', line 49

def node_running?
  if mac?
    return true if %x[ps aux | grep -i node | grep -v grep | wc -l].to_i > 0
  else
    return true if %x[tasklist /FI "IMAGENAME eq node.exe"].to_s.include? 'node'
  end
  false
end

#start_appium_server(id = nil, opt = '') ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mobmanager/mobile/appium/server/server.rb', line 8

def start_appium_server(id=nil, opt='')
  end_appium_server if node_running?
  puts 'Starting Appium server...'

  platform = ENV['PLATFORM']

  if platform == 'android'
    puts '-- Android Platform --'
    if ENV['ANDROID_PHONE'] == 'emulator'
      start_server(id, opt)
    else
      start_server(ENV['DEVICE'], opt)
    end
  end

  if platform == 'ios'
    puts '-- IOS Platform --'
    if ENV['IOS_PHONE'] == 'simulator'
      start_server(id, opt)
    else
      start_server(ENV['UIUD'], opt)
    end
  end

  sleep 5
  puts "Appium is listening...\n\n"
end