Sha256: 20afffd4f96dd1ac0740263828c4e4e33a42ad3258129883f265fa46bca5d0bd
Contents?: true
Size: 1.83 KB
Versions: 11
Compression:
Stored size: 1.83 KB
Contents
require 'random-port' require 'socket' require 'open3' class AppiumLocalService @@sessions_with_pid = [] def get_session_details @@sessions_with_pid end def launch_appium_sessions(device_details) sessions = [] p "Device details in Launch Appium Sessions = #{device_details}" p "Device details in Launch Appium Sessions = #{device_details.length}" device_details.each do |device_detail| session_id = create_session device_detail session_info = {} session_info["sessionUrl"] = session_id session_info["sessionCapabilities"] = device_detail sessions.push(session_info) end sessions end def launch_appium_session(device_detail) session_detail = create_session device_detail p session_detail return session_detail end def create_session(device_detail) RandomPort::Pool::SINGLETON.acquire do |port| @port = port end puts @port begin Timeout.timeout(5) do @pid = spawn(get_cmd(device_detail)) Process.wait @pid end end rescue Timeout::Error p @pid @ipaddress = Socket.ip_address_list[4].ip_address session_id = get_session_id add_session_details session_id return session_id end private def get_cmd(device_detail) case device_detail["platform"] when "ANDROID" return "appium -p #{@port} --bootstrap-port #{get_random_port}" when "IOS" return "appium -p #{@port} --webdriveragent-port #{get_random_port}" end end def get_random_port port = RandomPort::Pool.new.acquire return port end def get_session_id "http://#{@ipaddress}:#{@port}/wd/hub" end def add_session_details(session_id) session_details = {} session_details["session_id"] = session_id session_details["session_pid"] = @pid @@sessions_with_pid.push session_details end end
Version data entries
11 entries across 11 versions & 1 rubygems