Sha256: 783c869b7cb91fd2fedea9681f31810671217d60b3a3c75fea738a18a40ca52c

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

require 'faraday'
require 'utilities/waiter'
#
# Class to wrap Appium in a Rubyish way.
#
class AppiumServer
  include Waiter
  attr_accessor :port, :server

  def initialize(server: nil, port: nil)
    @server = server || 'localhost'
    @port = port || 4723
  end

  def quiet_cmd(in_string)
    system in_string + ' 1>nul 2>&1'
  end

  def start
    raise 'server already started' if started?
    quiet_cmd('start "appium" cmd /c appium')
    await -> { started? }
  end

  def started?
    Faraday.get("http://#{@server}:#{@port}/wd/hub/status")
    true
  rescue Faraday::ConnectionFailed
    false
  end

  def stop
    raise 'server not started' unless started?
    quiet_cmd('taskkill /f /fi "WINDOWTITLE eq appium" /t')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rutl-0.8.0 lib/rutl/appium/appium_server.rb