Appium starts iOS simulator TWICE for every test

Mac OSX 10.10.5
Xcode 7.2.0
iOS 9.2 Simulator
Python 2.7.11
Appium Server 1.5

I’ve observed that my iOS Simulator is specifically started TWICE for every single test. So a test that physically takes 10 seconds to execute is taking 90+ seconds waiting for the sim to boot twice and cleanup when completed. I don’t recall this happening last year (older Appium / Xcode) when I was last working on Appium.

I do not have fullReset specified in desired capabilities.

I see this logging during the first launch of the sim.

[debug] [iOS] Cleaning sim state. [debug] [iOSSim] Cleaning app data files for 'xxxxxxxx.app', 'com.xxxxx.xxxxxxxx' [iOSSim] Attempted to get an app path from a fresh simulator quickly launching the sim to populate its directories [debug] [iOSSim] Attempting to launch and quit the simulator, to create directory structure [debug] [iOSSim] Will launch with Safari? false [iOSSim] Starting simulator with command: open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID 5FA918BC-F429-494E-9997-CF3A0FD08970 [iOSSim] Tailing simulator logs until we encounter the string "System app "com.apple.springboard" finished startup" [iOSSim] We will time out after 60000ms [debug] [iOSSim] Waiting and extra 2000ms for the simulator to really finish booting [debug] [iOSSim] Done waiting extra time for simulator [iOSSim] Simulator booted in 22300ms [debug] [iOSSim] Killing all iOS Simulators [debug] [iOSSim] Building bundle path map [debug] [iOSSim] Building bundle path map [debug] [iOSSim] Could not find app directories to delete. It is probably not installed

Then it launches the simulator again at which point the test physically executes.

Then rinse and repeat for every… single… test… :slight_smile:

Post your capabilities & code.

Capabilities per Appium logging:

Appium] Creating new IosDriver session [Appium] Capabilities: [Appium] deviceName: 'iPhone 6' [Appium] nativeInstrumentsLib: false [Appium] app: '/Users/chrigrah/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxx-epzjepnxayzshqcudjnpftxnsjjd/Build/Products/xxxxxxxxxxxxx-iphonesimulator/xxxxxxxxxxxxx.app' [Appium] deviceReadyTimeout: 120 [Appium] newCommandTimeout: 360 [Appium] platformVersion: '9.2' [Appium] platformName: 'iOS' [BaseDriver] The following capabilities were provided, but are not recognized by appium: deviceReadyTimeout. [BaseDriver] Session created with session id: cc71db0c-dd31-4a94-b0bc-0cb1e1def584 [debug] [iOS] Not auto-detecting udid. [BaseDriver] Using local app '/Users/chrigrah/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxx-epzjepnxayzshqcudjnpftxnsjjd/Build/Products/xxxxxxxxxxxxx-iphonesimulator/xxxxxxxxxxxxx.app' [debug] [iOS] Removing any remaining instruments sockets [debug] [iOS] Cleaned up instruments socket /var/folders/t6/yqyxx6051ngf5trs40y2mhrh0000gn/T/instruments_sock [debug] [iOS] Setting Xcode version [debug] [iOS] Xcode version set to 7.2

Python code snippet. Nothing unusual going on here.

 class TestDashboard(unittest.TestCase):
     def setUp(self):
         desired_caps = desired_capabilities.get_desired_capabilities()
         self.driver = appium_server_connection.connect(desired_caps)
         self.driver.implicitly_wait(Globals.Implicit_Wait)
         self.dashboard_object = pageobjects.pages_dashboard.DashboardPageObject()

     def tearDown(self):
         self.driver.quit()

     def test_verify_dashboard_elements_exist(self):
         self.assertTrue(self.dashboard_object.is_dashboard_open())

Can’t tell from that. If you decide to post them I’ll respond.

def get_desired_capabilities():
    desired_caps = {}

    try:
        desired_caps['platformName'] = os.environ['PLATFORMNAME']
        desired_caps['platformVersion'] = os.environ['PLATFORMVERSION']
        desired_caps['deviceName'] = os.environ['DEVICENAME']
        desired_caps['app'] = os.environ['APP']
        desired_caps['newCommandTimeout'] = 360   # Appium test script timeout, needs to be > auth refresh timeout
    except KeyError:
        print "ERROR:  Please set the environment variables for PLATFORMNAME, PLATFORMVERSION, DEVICENAME, and APP"
        exit(1)

I’m seeing this too. Looks like it’s built-in to appium. The logs indicate it launches and quits to “create directory structure”. It’s not clear what this directory structure is for. Didn’t seem necessary in Appium versions prior to 1.5

[debug] [iOSSim] Attempting to launch and quit the simulator, to create directory structure

[iOSSim] Tailing simulator logs until we encounter the string “System app “com.apple.springboard” finished startup”

I poked around the source code and looks like the double-launch comes from trying to clear out the app directories. Setting the “fullReset: true” capability fixed this for me, and is actually more consistent with the default behavior in appium 1.4.13.

fullReset is in fact much faster than trying to clear the app directories. Not sure why appium would default to that way.

1 Like

@vic Bingo! I tried some different caps but apparently not this one specifically.

I am having the same issue, did any one have work around?

With Appium 1.5.3 this is the fix:

This is happening for me with latest appium 1.6, iOS and Safari
full reset aint helping much :unamused:
anyone know how to get around it?

appium log (with caps):

[Appium] Welcome to Appium v1.6.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {“requiredCapabilities”:{},“desiredCapabilities”:{“nativeWebTap”:true,“deviceName”:“iPhone Simulator”,“automationName”:“XCUITest”,“browserName”:“safari”,“safariIgnoreFraudWarning”:true,“newCommandTimeout”:“120”,“platformVersion”:“10.0”,“fullReset”:“true”,“platformName”:“iOS”}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{“nativeWebTap”:true,"devi…
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] nativeWebTap: true
[Appium] deviceName: ‘iPhone Simulator’
[Appium] automationName: ‘XCUITest’
[Appium] browserName: ‘safari’
[Appium] safariIgnoreFraudWarning: true
[Appium] newCommandTimeout: ‘120’
[Appium] platformVersion: ‘10.0’
[Appium] fullReset: 'true’
[Appium] platformName: ‘iOS’
[debug] [XCUITest] XCUITestDriver version: 2.0.26
[BaseDriver] Capability ‘fullReset’ changed from string to boolean. This may cause unexpected behavior
[BaseDriver] Capability ‘newCommandTimeout’ changed from string (‘120’) to integer (120). This may cause unexpected behavior
[BaseDriver] Session created with session id: 59c870dd-e2f8-4522-a018-819ee0fdbd75
[debug] [XCUITest] Xcode version set to ‘8.0’
[debug] [XCUITest] iOS SDK Version set to ‘10.0’
[debug] [XCUITest] Changing deviceName from ‘iPhone Simulator’ to ‘iPhone 6’
[iOSSim] Constructing iOS simulator for Xcode version 8.0 with udid ‘CA7C6D33-DCC0-481F-816E-B074DCA720D0’
[debug] [XCUITest] Full reset requested. Cleaning and stopping simulator
[debug] [iOSSim] Killing any simulator daemons for CA7C6D33-DCC0-481F-816E-B074DCA720D0
[iOSSim] Cleaning simulator CA7C6D33-DCC0-481F-816E-B074DCA720D0
[debug] [iOSSim] Killing all iOS Simulators
[XCUITest] Determining device to run tests on: udid: ‘CA7C6D33-DCC0-481F-816E-B074DCA720D0’, real device: false
[XCUITest] Safari test requested
[debug] [iOSLog] Starting iOS 10.0 simulator log capture
[debug] [iOSLog] System log path: /Users/rafalfusik/Library/Logs/CoreSimulator/CA7C6D33-DCC0-481F-816E-B074DCA720D0/system.log
[XCUITest] Setting up simulator
[debug] [iOS] No reason to set locale
[debug] [iOS] Setting iOS and app preferences
[debug] [iOS] No simulator directories found.
[debug] [iOSSim] Attempting to launch and quit the simulator, to create directory structure
[debug] [iOSSim] Will launch with Safari? true
[iOSSim] Starting simulator with command: open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID CA7C6D33-DCC0-481F-816E-B074DCA720D0
[iOSSim] Tailing simulator logs until we encounter the string “SMS Plugin initialized”
[iOSSim] We will time out after 60000ms
[debug] [iOSSim] Waiting an extra 10000ms for the simulator to really finish booting
[debug] [iOSSim] Done waiting extra time for simulator
[iOSSim] Simulator booted in 35987ms
[iOSSim] Tailing simulator logs until we encounter the string “MobileSafari[”
[iOSSim] We will time out after 15000ms
[debug] [iOSSim] Safari started, waiting 3000ms for it to fully start
[debug] [iOSSim] Done waiting for Safari
[debug] [iOSSim] Killing all iOS Simulators
[debug] [iOS] Setting fraudulent website warning to ‘false’
[debug] [iOSSim] Updating Safari user settings
[debug] [iOSSim] Building bundle path map
[debug] [iOS] Updated plist files, rebooting the simulator if it’s already open
[debug] [iOS] Killing the simulator
[debug] [iOSSim] Killing all iOS Simulators
[XCUITest] Simulator with udid ‘CA7C6D33-DCC0-481F-816E-B074DCA720D0’ not booted. Booting up now
[debug] [iOSSim] Killing all iOS Simulators
[iOSSim] Starting simulator with command: open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID CA7C6D33-DCC0-481F-816E-B074DCA720D0
[iOSSim] Tailing simulator logs until we encounter the string “SMS Plugin initialized”

Seeing it with latest appium 1.6.0

‘safariIgnoreFraudWarning’: True – comment it out !

did you manage to resolve this I am having the same issue?