I am using cucumber with ruby for mobile tests using appium and I wanted to have distributed tests across multiple simulators in the same mac. I tried implementing the multi thread execution creating two different appium servers for two simulators.
The below code, starts the appium server, However doesnt proceed starting the tests, not sure what am I missing
Any help is great appreciated
require 'appium_lib'
require 'selenium-cucumber'
require 'selenium-webdriver'
require 'rest_client'
require 'json'
require 'mysql2'
require 'thread'
def device1
{
caps:
{
platformName: "iOS",
deviceName: "iPhone Simulator", #update device as per your need
app: (File.join(File.dirname(__FILE__), "something.app")),
bundleId: "something",
automationName: "XCUITest",
xcodeOrgId: "something",
xcodeSigningId: "iPhone ",
noReset: "true",
fullReset: "false",
showIOSLog: "true",
autoAcceptAlerts: "true",
showXcodeLog: "true",
useNewWDA: "true",
resetOnSessionStartOnly: "true"
}
}
end
def device2
{
caps:
{
platformName: "iOS",
deviceName: "iPhone Simulator", #update device as per your need
app: (File.join(File.dirname(__FILE__), "something.app")),
bundleId: "something",
automationName: "XCUITest",
xcodeOrgId: "something",
xcodeSigningId: "iPhone ",
noReset: "true",
fullReset: "false",
showIOSLog: "true",
autoAcceptAlerts: "true",
showXcodeLog: "true",
useNewWDA: "true",
resetOnSessionStartOnly: "true"
}
}
end
def start_app(device_id,port_num)
caps_config= {platformName: "iOS",deviceName: "iPhone Simulator",app: (File.join(File.dirname(__FILE__), "something.app")),bundleId: "something",
automationName: "XCUITest", xcodeOrgId: "something",xcodeSigningId: "iPhone Developer", udid: device_id}
appium_lib_config={ port: port_num}
opts={caps:caps_config,appium_lib:appium_lib_config}
orig = Appium::Driver.new(opts)
return orig
end
def test(device1,device2)
cmd1 = "appium -p 4723 -bp 4002 -U " + device1
cmd2 = "appium -p 4724 -bp 4003 -U " + device2
system(cmd1)
system(cmd2)
sleep 20
threads = []
threads << Thread.new {
orig = start_app(device1,4000)
dr = orig.start_driver }
threads << Thread.new {
orig = start_app(device2,4001)
dr = orig.start_driver }
end
I am calling this code using the function test(device1, device2)
where device1 and device2 are its udid’s respectively
The output I get
Welcome to Appium v1.7.0
[Appium] Non-default server args:
[Appium] bootstrapPort: 4002
[Appium] udid: (something)
[Appium] Deprecated server args:
[Appium] -U,--udid => --default-capabilities '{"udid":"something"}'
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium] udid: 'something'
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
@KazuCocoa @wreed Could you please take a look at this with your appium_lib
eyes please?