Class: AppiumServer
- Inherits:
-
Object
- Object
- AppiumServer
- Includes:
- Waiter
- Defined in:
- lib/rutl/appium/appium_server.rb
Overview
Class to wrap Appium in a Rubyish way.
Constant Summary
Constants included from Waiter
Waiter::DEFAULT_TIMEOUT, Waiter::POLL_SLEEP_TIME
Instance Attribute Summary collapse
-
#port ⇒ Object
Returns the value of attribute port.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(server: nil, port: nil) ⇒ AppiumServer
constructor
A new instance of AppiumServer.
- #quiet_cmd(in_string) ⇒ Object
- #start ⇒ Object
- #started? ⇒ Boolean
- #stop ⇒ Object
Methods included from Waiter
Constructor Details
#initialize(server: nil, port: nil) ⇒ AppiumServer
Returns a new instance of AppiumServer.
10 11 12 13 |
# File 'lib/rutl/appium/appium_server.rb', line 10 def initialize(server: nil, port: nil) @server = server || 'localhost' @port = port || 4723 end |
Instance Attribute Details
#port ⇒ Object
Returns the value of attribute port.
8 9 10 |
# File 'lib/rutl/appium/appium_server.rb', line 8 def port @port end |
#server ⇒ Object
Returns the value of attribute server.
8 9 10 |
# File 'lib/rutl/appium/appium_server.rb', line 8 def server @server end |
Instance Method Details
#quiet_cmd(in_string) ⇒ Object
15 16 17 |
# File 'lib/rutl/appium/appium_server.rb', line 15 def quiet_cmd(in_string) system in_string + ' 1>nul 2>&1' end |
#start ⇒ Object
19 20 21 22 23 |
# 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? ⇒ Boolean
25 26 27 28 29 30 |
# 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 ⇒ Object
32 33 34 35 |
# 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 |