iOS Appium Automation Testing Setup Tips

  • Good materials:
  • Follow https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md to setup:
    • libimobiledevice – install using brew install libimobiledevice --HEAD
    • ios-deploy – install using npm install -g ios-deploy
    • { xcodeOrgId: <Team ID>, xcodeSigningId: iPhone Developer }
      # <Team ID> is a 10 chars ID from your team account. If you have fastlane build configure, you can find from there.
    • If you meet:
      • [XCUITest] [ 70%] VerifyingApplication [XCUITest] ‘. Stderr: ‘2019-02-25 18:56:53.483 ios-deploy[15543:11667215] [ !! ] Error 0xe8008017: A signed resource has been added, modified, or deleted. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0) [XCUITest] ‘. [XCUITest] Error: Could not install app: ‘Command ‘ios-deploy –id e03ea2d4ee568fdb8a1a3ea7a6cd5573d3684d6e –bundle /var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app’ exited with code 253′

        Check if your ipa contains any special chars in the file name, mine:
        codesign -v –verbose /var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app /var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app: a sealed resource is missing or invalid file added: /private/var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app/Images/Group∩╝ì02.png file added: /private/var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app/Images/Group∩╝ì01.png file added: /private/var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app/Images/Group∩╝ì03.png file added: /private/var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app/Images/Group∩╝ì04.png file missing: /private/var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app/Images/Group-04.png file missing: /private/var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app/Images/Group-03.png file missing: /private/var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/BeePOS-TH.app/Images/Group-02.png file missing: /private/var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-63761-15x74l9.m7xk/Payload/xxx-TH.app/Images/Group-01.png
        After fixing the file name issue and rebuild I can install the .ipa to a real device.
    • If you meet
      • [XCUITest] ‘. Stderr: ‘2019-02-25 23:45:33.230 ios-deploy[22888:11854485] [ !! ] Error 0xe8008016: The executable was signed with invalid entitlements. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0) [XCUITest] ‘. [XCUITest] Error: Could not install app: ‘Command ‘ios-deploy –id e03ea2d4ee568fdb8a1a3ea7a6cd5573d3684d6e –bundle /var/folders/qw/3n_wydks4wx4pw_ntsm2h9xrzhfnbl/T/2019125-17875-1b1nr5g.ab93/Payload/BeePOS-TH-Enterprise.app’ exited with code 253′ [XCUITest] at IOSDeploy.install (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/lib/ios-deploy.js:40:13) [XCUITest] at process._tickCallback (internal/process/next_tick.js:68:7) [XCUITest] Not clearing log files. Use clearSystemFiles capability to turn on.

        You have to build your .ipa with a real provisioning profile. ‘wildcard provisioning profile’ will not work here.
    • If you meet
      • “info XCUITest xcodebuild exited with code ’65’ and signal ‘null'”, it means you fail to install and run WebDriverAgent on your real device. Follow https://github.com/imurchie/appium-xcuitest-driver/blob/isaac-rs/docs/real-device-config.md#basic-manual-configuration (I followed the “Full manual configuration” section:
        •     $ which appium
              /path/where/installed/bin/appium
          
              mkdir -p Resources/WebDriverAgent.bundle
              ./Scripts/bootstrap.sh -d
        • Open WebDriverAgent.xcodeproj and build the project:
          • You will need to change the “Product Bundle Identifier” from com.facebook.WebDriverAgentRunner to something that Xcode will accept
          • Then cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
            • xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test
              
          • To run WebDriverAgent, just (‘without the test’):
            • xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>'
  • Your appium desired capabilities should be like,
    • driver = webdriver.Remote(
          command_executor=EXECUTOR,
          desired_capabilities={
              'app': IOS_APP_PATH,
              'platformName': 'iOS',
              'automationName': 'XCUITest',
              "xcodeOrgId": "yyyyyxxxxx",
              'udid': 'e03ea2d4ee568fdb8a1a3ea7a6cdyyyyyyxxxxxd',
              "xcodeSigningId": "iPhone Developer",
              "updateWDABundleId": "com.seagroup.WebDriverAgentRunner",
              'platformVersion': os.getenv('IOS_PLATFORM_VERSION') or '12.1.4',
              'deviceName': os.getenv('IOS_DEVICE_NAME') or 'iPad',
              "bootstrapPath": "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent",
              "agentPath": "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj"
          }
      )
  • x