在AWS Device Farm上使用Node.js webdriver.io时使用AMDeviceSecureInstallApplication

问题描述

我已经在Android设备上成功运行了测试。但仍在与iOS斗争。 在本地,一切运行正常,但是在AWS上,它不会启动该应用程序。 我可以看到正在安装,但无法启动 我已在要旨https://gist.github.com/cescoferraro/2196382c88f6c0c50bd8f2f16cf4fb61

添加了所有相关代码
const awsopts = {
    path: '/wd/hub',port: 4723,capabilities: {
        automationName: "XCUITest",platformName: process.env.DEVICEFARM_DEVICE_PLATFORM_NAME,udid: "auto",app: process.env.DEVICEFARM_APP_PATH,},};

定义

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.7.2 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.14.2
      # For your convenience,we have preinstalled the following 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,and 1.17.1
      # For iOS devices on OS version 13.4 and above,please use Appium version 1.17.1 for the best possible experience
      # 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:
      - export APPIUM_VERSION=1.14.2
      - avm $APPIUM_VERSION
      - 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 4 different pre-built versions of WebDriverAgent,and each is suggested for different versions of Appium:
      # 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 your UDID of the device not contain any "-" characters
      # So,we will create a new environment variable of your UDID specifically for Appium based on your Appium version
      - >-
        if [ $(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 14.9.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

  # The pre-test phase includes commands that setup your test environment.
  pre_test:
    commands:
      # We recommend starting 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"
      - >-
        appium --log-timestamp
        --default-capabilities "{\"usePrebuiltWDA\": true,\"derivedDataPath\":\"$DEVICEFARM_WDA_DERIVED_DATA_PATH\",\"deviceName\": \"$DEVICEFARM_DEVICE_NAME\",\"platformName\":\"$DEVICEFARM_DEVICE_PLATFORM_NAME\",\"app\":\"$DEVICEFARM_APP_PATH\",\"automationName\":\"XCUITest\",\"udid\":\"$DEVICEFARM_DEVICE_UDID_FOR_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/*

      - echo "Start Appium Node test"
      # Enter the command below to start the tests . The comamnd 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:
      - npm run ios

  # 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

解决方法

能否请您分享iOS运行的运行网址?

您还可以尝试使用空白功能吗?

const awsopts = {
                 path: '/wd/hub',port: 4723,capabilities: {
                  },};

因为设备场平台已在pre_test阶段将其设置为默认功能。