[iOS][Appium]Process Arguments by Appium for XCUITest, iOS

Today, I’d like to leave a tip. I’ve implemented test cases using this article for over 3 years. It helped us to control test environment more stable and fast.

XCUITest can set process arguments for Instrumentation.

According to https://github.com/appium/appium-xcuitest-driver#desired-capabilities, you can set processArguments in capability and the test app can get the value via ProcessInfo.

You can set the value via below’s Environment Variables.

Screen Shot 2018-06-10 at 20.54.14

Client

Next code is Ruby based.

IOS_OPS = {
  caps: {
    platformName: :ios,
    automationName: 'XCUITest',
    ...
    processArguments: {
      env: {
        "PROCESS_VALUE": "process value"
      }
    }
  },
  appium_lib: {
    ...
  }
}.freeze

By processArguments, you can set the environment variables.

Test app

The processArguments can get via ProcessInfo like below.

import Foundation

let env = ProcessInfo.processInfo.environment
env["PROCESS_VALUE"] // "process value"

Next image isn’t the above. But I believe it help you understand ProcessInfo.processInfo.environment.
Screen Shot 2018-06-10 at 20.15.50

You can control some behaviour using the argument. For example, URLs or interval for network.

[update]

Android has optionalIntentArguments to give intent arguments in start activities.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.