How to work with Appium 2.0 with AWS Device Farm.

1

Latest iOS versions support Appium 2.0 WebDriverAgent, How can we start working on Appium 2.0 in AWS Device Farm?

質問済み 1年前2368ビュー
3回答
0

Thank you for reaching out us regarding the above query. I would like to share that, at this point of time Appium 2.0.0-beta is not supported officially on Device Farm. And therefore we would not be able to guarantee the success of the test runs. Despite this, you may try to install the latest version of Appium (2.0.0-beta.46) in my Device Farm by editing the YAML-formatted Test Specification file. As such you may try modifying your test environment similar to the below in order to upgrade your Appium version.

I have included the following commands which can be added to the YAML file which install the latest version of npm and Appium:

  # Installing Latest Version of Appium
  - npm install -g npm
  - npm i -g appium@next
  - appium -v

Additionally please note that the below mentioned output is received if the npm version is not upgraded: [DeviceFarm] appium [Appium] npm version must be at least >=8; current is 6.14.16. Run "npm install -g npm" to upgrade.

Hence you may consider trying the above, however as the service does not officially support Appium 2.x you may observe unintended or sporadic behaviour when using the unsupported version on Device Farm. Please note that this is marked as a feature request with the DeviceFarm service team and they are working on the same. While I am unable to comment on if/when this feature may get released, I request you to keep an eye on our What's New and Blog pages for any new feature announcements.

Having said that, in case you face further challenges, please feel free to open a support case with AWS using the following link.

回答済み 1年前
0

Hello,

I recently just went through this and got appium 2.0 to work in device farm. Below is a version of the yml file that is working for us.

version: 0.1

# Phases are collection of commands that get executed on Device Farm.
phases:
  # The install phase includes commands that install dependencies that your tests use.
  # Default dependencies for testing frameworks supported on Device Farm are already installed.
  install:
    commands:
      # This test execution environment uses Appium version 1.9.1 by default, however we enable you to change it using the Appium version manager (avm)
      # An example "avm" command below changes the version to 1.19.0
      # For your convenience, we have pre-installed the following Appium versions: 1.9.1, 1.10.1, 1.11.1, 1.12.1, 1.13.0, 1.14.1, 1.14.2, 1.15.1, 1.16.0, 1.17.1, 1.18.0, 1.18.1, 1.18.2, 1.18.3, and 1.19.0
      # For iOS Devices on OS version 14.2 and above, please use Appium Version 1.19.0 or higher.
      # For iOS devices on OS version 14.0 and above, please use Appium version 1.18.0 or higher.
      # For iOS devices on OS version 13.4 through 13.7, please use Appium version 1.17.1 or higher.
      # Additionally, for iOS devices on OS version 13.0 through 13.3, please use Appium version 1.16.0 or higher.
      # To use one of these Appium versions, change the version number in the "avm" command below to your desired version:
      - nvm install 16
      - export APPIUM_VERSION=2.0.0-beta.57
      - avm $APPIUM_VERSION
      - echo $APPIUM_VERSION
      - mkdir /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin
      - ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium  /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js

      # Device farm provides different pre-built versions of WebDriverAgent, and each is suggested for different versions of Appium:
      # DEVICEFARM_WDA_DERIVED_DATA_PATH_V6: this version is suggested for Appium 1.18.2, 1.18.3, and 1.19.0. V6 is built from the following source code: https://github.com/appium/WebDriverAgent/releases/tag/v2.20.8
      # DEVICEFARM_WDA_DERIVED_DATA_PATH_V5: this version is suggested for Appium 1.18.0 and 1.18.1. V5 is built from the following source code: https://github.com/appium/WebDriverAgent/releases/tag/v2.20.2
      # DEVICEFARM_WDA_DERIVED_DATA_PATH_V4: this version is suggested for Appium 1.17.1. V4 is built from the following source code: https://github.com/appium/WebDriverAgent/releases/tag/v2.14.1
      # DEVICEFARM_WDA_DERIVED_DATA_PATH_V3: this version is suggested for Appium 1.16.0. V3 is built from the following source code: https://github.com/appium/WebDriverAgent/releases/tag/v2.3.2
      # DEVICEFARM_WDA_DERIVED_DATA_PATH_V2: this version is suggested for Appium 1.15.1. V2 is built from the following source code: https://github.com/appium/WebDriverAgent/tree/v1.3.5
      # DEVICEFARM_WDA_DERIVED_DATA_PATH_V1: this version is suggested for Appium 1.9.1 through 1.14.2. V1 is built from the following source code: https://github.com/appium/WebDriverAgent/tree/2dbbf917ec2e4707bae9260f701d43c82b55e1b9
      # We will automatically configure your WebDriverAgent version based on your Appium version using the following code.

      # For users of Appium versions 1.15.0 and higher, your Appium version requires that the UDID of the device not contain any "-" characters
      # So, we will create a new environment variable of the UDID specifically for Appium based on your Appium version
      - >-
        if [ $(echo $APPIUM_VERSION | cut -d "." -f4) -ge 19 ];
        then
          DEVICEFARM_DEVICE_UDID_FOR_APPIUM=$(echo $DEVICEFARM_DEVICE_UDID | tr -d "-");
          DEVICEFARM_WDA_DERIVED_DATA_PATH=$DEVICEFARM_WDA_DERIVED_DATA_PATH_V6;
        elif [ $(echo $APPIUM_VERSION | cut -d "." -f2) -ge 19 ];
        then
          DEVICEFARM_DEVICE_UDID_FOR_APPIUM=$(echo $DEVICEFARM_DEVICE_UDID | tr -d "-");
          DEVICEFARM_WDA_DERIVED_DATA_PATH=$DEVICEFARM_WDA_DERIVED_DATA_PATH_V6;
        elif [ $(echo $APPIUM_VERSION | cut -d "." -f2) -ge 18 ];
        then
          DEVICEFARM_DEVICE_UDID_FOR_APPIUM=$(echo $DEVICEFARM_DEVICE_UDID | tr -d "-");
          DEVICEFARM_WDA_DERIVED_DATA_PATH=$DEVICEFARM_WDA_DERIVED_DATA_PATH_V5;
        elif [ $(echo $APPIUM_VERSION | cut -d "." -f2) -ge 17 ];
        then
          DEVICEFARM_DEVICE_UDID_FOR_APPIUM=$(echo $DEVICEFARM_DEVICE_UDID | tr -d "-");
          DEVICEFARM_WDA_DERIVED_DATA_PATH=$DEVICEFARM_WDA_DERIVED_DATA_PATH_V4;
        elif [ $(echo $APPIUM_VERSION | cut -d "." -f2) -ge 16 ];
        then
          DEVICEFARM_DEVICE_UDID_FOR_APPIUM=$(echo $DEVICEFARM_DEVICE_UDID | tr -d "-");
          DEVICEFARM_WDA_DERIVED_DATA_PATH=$DEVICEFARM_WDA_DERIVED_DATA_PATH_V3;
        elif [ $(echo $APPIUM_VERSION | cut -d "." -f2) -ge 15 ];
        then
          DEVICEFARM_DEVICE_UDID_FOR_APPIUM=$(echo $DEVICEFARM_DEVICE_UDID | tr -d "-");
          DEVICEFARM_WDA_DERIVED_DATA_PATH=$DEVICEFARM_WDA_DERIVED_DATA_PATH_V2;
        else
          DEVICEFARM_DEVICE_UDID_FOR_APPIUM=$DEVICEFARM_DEVICE_UDID;
          DEVICEFARM_WDA_DERIVED_DATA_PATH=$DEVICEFARM_WDA_DERIVED_DATA_PATH_V1;
        fi

      # By default the node version installed is 10.9.0
      # you can switch to an alternate node version using below command.
      # - nvm install 10.13.0

      # Unpackage and install the node modules that you uploaded in the test phase.
      - echo "Navigate to test package directory"
      - cd $DEVICEFARM_TEST_PACKAGE_PATH
      - npm install *.tgz
      # Install appium driver for xcuitest
      - appium driver install xcuitest

  # The pre-test phase includes commands that set up your test environment.
  pre_test:
    commands:
      # We recommend starting the appium server process in the background using the command below.
      # Appium server log will go to $DEVICEFARM_LOG_DIR directory.
      # The environment variables below will be auto-populated during run time.
      - echo "Start appium server"
      - echo $DEVICEFARM_DEVICE_PLATFORM_NAME
      - >-
        appium server --log-timestamp --default-capabilities "{\"appium:usePrebuiltWDA\": true, \"appium:derivedDataPath\":\"$DEVICEFARM_WDA_DERIVED_DATA_PATH\",
        \"appium:deviceName\": \"$DEVICEFARM_DEVICE_NAME\", \"appium:platformName\":\"$DEVICEFARM_DEVICE_PLATFORM_NAME\", \"appium:app\":\"$DEVICEFARM_APP_PATH\",
        \"appium:automationName\":\"XCUITest\", \"appium:udid\":\"$DEVICEFARM_DEVICE_UDID_FOR_APPIUM\", \"appium:platformVersion\":\"$DEVICEFARM_DEVICE_OS_VERSION\"}"
        >> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &

      - >-
        start_appium_timeout=0;
        while [ true ];
        do
            if [ $start_appium_timeout -gt 60 ];
            then
                echo "appium server never started in 60 seconds. Exiting";
                exit 1;
            fi;
            grep -i "Appium REST http interface listener started on 0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
            if [ $? -eq 0 ];
            then
                echo "Appium REST http interface listener started on 0.0.0.0:4723";
                break;
            else
                echo "Waiting for appium server to start. Sleeping for 1 second";
                sleep 1;
                start_appium_timeout=$((start_appium_timeout+1));
            fi;
        done;

  # The test phase includes commands that start your test suite execution.
  test:
    commands:
      # Your test package is downloaded in $DEVICEFARM_TEST_PACKAGE_PATH
      # However, we must navigate to its subdirectory "node_modules/*", as this directory has your test code and dependency node modules
      - echo "Navigate to test code directory"
      - cd $DEVICEFARM_TEST_PACKAGE_PATH/node_modules/*
      - npm install

      - echo "Start Appium Node test"
      # Enter the command below to start the tests . The command should be similar to what you use to run the tests locally.
      # For e.g. assuming you run your tests locally using command "node YOUR_TEST_FILENAME.js.", enter the same command below:
      - npx wdio run wdio.conf.ts

  # The post test phase includes commands that are run after your tests are executed.
  post_test:
    commands:

# The artifacts phase lets you specify the location where your tests logs, device logs will be stored.
# And also let you specify the location of your test logs and artifacts which you want to be collected by Device Farm.
# These logs and artifacts will be available through ListArtifacts API in Device Farm.
artifacts:
  # By default, Device Farm will collect your artifacts from following directories
  - $DEVICEFARM_LOG_DIR

The changes worth noting are the following:

This one handles that the version number is not the same format since it has the beta at the end.

 if [ $(echo $APPIUM_VERSION | cut -d "." -f4) -ge 19 ];
        then
          DEVICEFARM_DEVICE_UDID_FOR_APPIUM=$(echo $DEVICEFARM_DEVICE_UDID | tr -d "-");
          DEVICEFARM_WDA_DERIVED_DATA_PATH=$DEVICEFARM_WDA_DERIVED_DATA_PATH_V6;

This now has appium: prefixed on each capability as that is outlined in the appium 2.0 docs.

      - >-
        appium server --log-timestamp --default-capabilities "{\"appium:usePrebuiltWDA\": true, \"appium:derivedDataPath\":\"$DEVICEFARM_WDA_DERIVED_DATA_PATH\",
        \"appium:deviceName\": \"$DEVICEFARM_DEVICE_NAME\", \"appium:platformName\":\"$DEVICEFARM_DEVICE_PLATFORM_NAME\", \"appium:app\":\"$DEVICEFARM_APP_PATH\",
        \"appium:automationName\":\"XCUITest\", \"appium:udid\":\"$DEVICEFARM_DEVICE_UDID_FOR_APPIUM\", \"appium:platformVersion\":\"$DEVICEFARM_DEVICE_OS_VERSION\"}"
        >> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &
回答済み 1年前
0

Device Farm supports all Appium 1.x and 2.x server versions. Please refer to the following doc for further information : https://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-appium.html

AWS
回答済み 18日前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン