Class: TestCentricity::AppiumServer
- Defined in:
- lib/testcentricity_web/appium_server.rb
Instance Attribute Summary collapse
-
#process ⇒ Object
Returns the value of attribute process.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ AppiumServer
constructor
A new instance of AppiumServer.
-
#running? ⇒ Boolean
Check to see if Appium Server is running.
-
#start ⇒ Object
Start the Appium Server.
-
#stop ⇒ Object
Stop the Appium Server.
Constructor Details
#initialize(params = {}) ⇒ AppiumServer
Returns a new instance of AppiumServer.
12 13 14 |
# File 'lib/testcentricity_web/appium_server.rb', line 12 def initialize(params={}) @params = params end |
Instance Attribute Details
#process ⇒ Object
Returns the value of attribute process.
10 11 12 |
# File 'lib/testcentricity_web/appium_server.rb', line 10 def process @process end |
Instance Method Details
#running? ⇒ Boolean
Check to see if Appium Server is running
41 42 43 44 45 46 47 48 |
# File 'lib/testcentricity_web/appium_server.rb', line 41 def running? response = nil begin response = Net::HTTP.get_response(URI('http://127.0.0.1:4723/wd/hub/sessions')) rescue end response && response.code_type == Net::HTTPOK end |
#start ⇒ Object
Start the Appium Server
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/testcentricity_web/appium_server.rb', line 19 def start # terminate any currently running Appium Server if running? system('killall -9 node') puts 'Terminating existing Appium Server' sleep(5) puts 'Appium Server is being restarted' else puts 'Appium Server is starting' end # start new Appium Server @process = ChildProcess.build(*parameters) process.start # wait until confirmation that Appium Server is running wait = Selenium::WebDriver::Wait.new(timeout: 30) wait.until { running? } puts "Appium Server is running - PID = #{process.pid}" end |
#stop ⇒ Object
Stop the Appium Server
53 54 55 56 |
# File 'lib/testcentricity_web/appium_server.rb', line 53 def stop process.stop puts 'Appium Server has been terminated' end |