class AppiumServer

Class to wrap Appium in a Rubyish way.

Attributes

port[RW]
server[RW]

Public Class Methods

new(server: nil, port: nil) click to toggle source
# File lib/rutl/appium/appium_server.rb, line 10
def initialize(server: nil, port: nil)
  @server = server || 'localhost'
  @port = port || 4723
end

Public Instance Methods

quiet_cmd(in_string) click to toggle source
# File lib/rutl/appium/appium_server.rb, line 15
def quiet_cmd(in_string)
  system in_string + ' 1>nul 2>&1'
end
start() click to toggle source
# File lib/rutl/appium/appium_server.rb, line 19
def start
  raise 'server already started' if started?
  quiet_cmd('start "appium" cmd /c appium')
  await -> { started? }
end
started?() click to toggle source
# File lib/rutl/appium/appium_server.rb, line 25
def started?
  Faraday.get("http://#{@server}:#{@port}/wd/hub/status")
  true
rescue Faraday::ConnectionFailed
  false
end
stop() click to toggle source
# File lib/rutl/appium/appium_server.rb, line 32
def stop
  raise 'server not started' unless started?
  quiet_cmd('taskkill /f /fi "WINDOWTITLE eq appium" /t')
end