Appium - Custom capabilities

Hi all,

Guys need your help.

Anyone has the experience working with custom capabilities for appium server?

For e.g.
For tests that should be tested on test environment I need to set the custom capability for the appium server that starts the app pointing on test environment, for production - to production.

I heard that in iOS app it possible to build the project if the url comes with for ex. test environment, API switches to the test environment, if other value - to other API.

Thanks a lot. :slight_smile:

why you do not want to make all in code?

  1. example of customatization with testNG below. you can create whatever parameters you need and process them in test code e.g. to take application configured for test environment or (if application supports) repoint it itself in code.

  2. about iOS code suggest to talk with developers to create different schemas for each test environment.
    e.g. example how we build with jenkins for Simulator:

xcodebuild -workspace XXXX.xcworkspace -scheme XXXXAlpha -sdk iphonesimulator10.2 -configuration Debug -destination "platform=iOS Simulator,name=iPhone 6s,OS=10.2" -derivedDataPath output clean build

<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="test_iOS">
    <listeners>
        <listener class-name="com.xxxx.base.RetryListener" />
        <listener class-name="com.xxxx.base.TestListener" />
    </listeners>
    <parameter name="runDestination" value="Local"/>
    <parameter name="devicePlatform" value="iOS"/>
    <parameter name="osVersion" value="10.2"/>
    <parameter name="appType" value="alpha"/>
    <parameter name="appiumServer2_Port" value="4726"/> <!-- 4725 Android_1, 4726 Android_2, 4727 iOS-->

    <!--
    <parameter name="osVersion" value="8.4"/>
    <parameter name="appType" value="Group"/>
    <parameter name="deviceUDID" value="3059d615cfff135bf283ded0d5d4d67c6132502b"/> //iPad mini
    <parameter name="bundleID" value="com.???"/>
    <parameter name="someData" value="???"/>

    <parameter name="runDestination" value="Local"/>
    <parameter name="devicePlatform" value="iOS fullReset/>

    -->

    <test name="test" preserve-order="true">
        <parameter name="devicePlatform" value="iOS"/> <!-- fullReset -->
        <parameter name="deviceName" value="iPhone 6s"/> <!-- iPad Air  iPhone 6s -->
        <classes>
            <class name="com.xxxxx.tests.ios.webLinks">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
        </classes>
    </test>
</suite>

Thanks @Aleksei, the idea of 2 apps was replaced by having one build with switcher, so while manual QA is testing it’s easier to switch manually Test vs Production.

But does it possible to implement it in appium call, by sending the parameter(flag) with needed environment?
Cause in iOS it’s possible to receive right flag and to switch the api calls.

Thanks a lot

Say how it is working now with your application. How you point it on dev or prod in simulator or real device without appium.

This is my question I don’t know how to do it. :slight_smile:

Now by default the app is installed with already pointing on Prod, si you need manually switch the environment or create additional steps to Go to iPhone Settings > MyApp > Environment (and here switch to the needed env.)

so you have options:

  1. automate in Simulator ONLY your steps iPhone Settings > MyApp > Environment
  2. ask dev to add schemes with preconfigured environments
  3. ask dev to move environment settings into some menu option that will appear with debug build
  4. the way you suggest as i understood is add some parameter when we start client and it will switch into needed environment. this also will need dev support first. it can be done using “processArguments” flag when you start driver. (according to documentation. never tried.)

Sounds good :slight_smile:
Option 4 is what I’ve been searching, but need to try it. :slight_smile:

Thank you @Aleksei for the advices.

Thanks a lot @Aleksei,

We’ve implemented the 4th solution. :slight_smile: it works fine.

We’ve used appium.processArguments = {“args”: ["-environment", “test”]}

just in case if i need it later you added it like:

            List<String> processArgs = new ArrayList<>(Arrays.asList(
                    "-environment", "test"
            ));
            final JSONObject argsValue = new JSONObject();
            argsValue.put("args", processArgs);
            capabilities.setCapability("processArguments", argsValue);

for the Android, we’ve implemented this:

{
“platformName”: “Android”,
“platformVersion”: “7.1.1”,
“deviceName”: “emulator-5554”,
“automationName”: “UIAutomator2”,
“app”: “/pathToApp/app.apk”,
"intentAction": “test”,
“platform”: “Android”,
“avd”: “Nexus_5”
}