I have an automation framework running in MAC which open a simulator trough Appium. I want to open multiple iOS simulator in order to run different test cases at the same time, what are the options that I have?
-
You can do that but on multiple Mac not on the same Mac !! – Pankaj Kumar Katiyar Mar 07 '16 at 06:01
3 Answers
Since Xcode 9 and Appium 1.7, this is now possible. The key is the wdaLocalPort
capability. Each simulator needs its own port.
Here's an example, I use ruby, but it will be similar in other languages as well:
require 'appium_lib'
opts = {
caps: {
automationName: 'XCUITest',
platformName: 'iOS',
deviceName: 'iPhone 7',
wdaLocalPort: 8001,
app: 'Example.app',
},
}
10.times do
driver = Appium::Driver.new(opts, true)
driver.start_driver.manage.timeouts.implicit_wait = 10
driver.find_element(:name, 'Button').click
driver.driver_quit
end
I couldn't be bothered to implement the concurrency, so you'll have to manually execute the next script at the same time as the first one.
require 'appium_lib'
opts = {
caps: {
automationName: 'XCUITest',
platformName: 'iOS',
deviceName: 'iPhone 8',
wdaLocalPort: 8002,
app: 'Example.app',
},
}
10.times do
driver = Appium::Driver.new(opts, true)
driver.start_driver.manage.timeouts.implicit_wait = 10
driver.find_element(:name, 'Button').click
driver.driver_quit
end
I haven't played with this too much, but when I used two simulators, I ran twice the amount of tests in the same time. Would be interesting to see how well it scales.
EDIT: Turns out that I could be bothered to implement the concurrency:
require 'appium_lib'
device_names = [
'iPhone 6',
'iPhone 6s',
'iPhone 7',
'iPhone 8',
]
def test(device_name, port)
opts = {
caps: {
automationName: 'XCUITest',
platformName: 'iOS',
deviceName: device_name,
wdaLocalPort: port,
app: 'Example.app',
},
}
driver = Appium::Driver.new(opts, true)
driver.start_driver.manage.timeouts.implicit_wait = 10
driver.find_element(:name, 'Button').click
driver.driver_quit
end
device_names.each_with_index do |device_name, i|
fork {
10.times do
test(device_name, 8000+i)
end
}
end
Process.waitall
The above will launch as many simulators as you specify in the device_names
array and run 10 tests on each of them. I also wrote a more complicated script for benchmarking. Between 3 and 4 simulators I had less than a 10% increase in performance, so running more than 4 doesn't seem worth while, but I suppose that depends on your system.
As you launch more and more simulators, you will likely run out of system resources. Here's how you deal with that: https://stackoverflow.com/a/46819409/310121

- 40,889
- 25
- 119
- 135
The technical limitation of appium of 1 device in 1 mac can be solved by using Sauce Lab's mobile cloud which presents running multiple simulators/devices at the same time. you need to enroll/signup to use them

- 1,313
- 1
- 8
- 15
Check this library https://github.com/facebook/FBSimulatorControl, it will give you the ability to run multiple IOS simulators in the same host.

- 311
- 4
- 11