class Cuesmash::AppiumServer

Provides an interface for starting the appium server

@author [jarod]

Attributes

format[RW]

Public: the output format for the tests

output[RW]

Public: the output directory for the tests

Public Instance Methods

start_server() click to toggle source

Run the appium server

# File lib/cuesmash/appium_server.rb, line 20
def start_server
  started

  command = 'appium --log-level debug'

  @stdin, @stdout, @stderr, @wait_thr = Open3.popen3(command)
  Logger.info "Appium started with pid: #{@wait_thr.pid}"

  if Logger.debug?
    [@stdout, @stderr].each do |stream|
      Thread.new do
        until (line = stream.gets).nil?
          Logger.debug "[Appium] #{line}"
        end
      end
    end
  end
  # looks like the we need to wait for the service to start up
  # This isn't good, we should create a check to verify first.
  sleep 3
end
stop_server() click to toggle source

Stop the appium server

# File lib/cuesmash/appium_server.rb, line 45
def stop_server
  Process.kill('INT', @wait_thr.pid)
  @stdin.close
  @stdout.close
  @stderr.close

  completed
end

Private Instance Methods

completed() click to toggle source

Output a nice message for completing

# File lib/cuesmash/appium_server.rb, line 66
def completed
  Logger.info 'Stopping Appium server 👌'
end
started() click to toggle source

Output a nice message for starting

# File lib/cuesmash/appium_server.rb, line 59
def started
  Logger.info 'Starting Appium Server'
end