Не удалось создать проблему с сеансом WDA в ферме устройств AWS с использованием appium с python

#appium #appium-ios #xcuitest #aws-device-farm

Вопрос:

Аппиум — 1.19.0

Версии iOS — 13.6, 14.0, 11.0.3, 14.0

Python v3.7

Тесты отлично работают на Android в ферме устройств AWS, так что это строго проблема, связанная с iOS. Из видео, которое предоставляет AWS, я вижу, что приложение установлено правильно, но, похоже, его нельзя запустить. Глядя на журналы appium, кажется, что сеанс WDA не может быть создан.

Спецификация теста YAML

 
# 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:
      # Device Farm support two major versions of Python, each with one minor version: 2 (minor version 2.7), and 3 (minor version 3.7).
      # The default Python version is 2, but you can switch to 3 by setting the following variable to 3:
      - export PYTHON_VERSION=3

      # This command will install your dependencies and verify that they're using the proper versions that you specified in your requirements.txt file. Because Device Farm preconfigures your environment within a
      # Python Virtual Environment in its set up phase, you can use pip to install any Python packages just as you would locally.
      - cd $DEVICEFARM_TEST_PACKAGE_PATH
      - . bin/activate
      - pip install -r requirements.txt

      # 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:
      - export APPIUM_VERSION=1.19.0
      - 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 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 "." -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

  # 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"
      - >-
        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>amp;1 amp;

      - >-
        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>amp;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 so we first change directory to that path.
      # We already set up python virtual environment on $DEVICEFARM_TEST_PACKAGE_PATH
      # and installed required libraries. You can run your test under $DEVICEFARM_TEST_PACKAGE_PATH
      - echo "Navigate to test package directory"
      - cd $DEVICEFARM_TEST_PACKAGE_PATH
      - echo "Start Appium Python test"
      # By default, the following command is used by Device Farm to run your Appium Python test.
      # The goal is to run all your tests files in the test package.
      # Alternatively, You may specify your customized command.
      # Note: For most use cases, the default command works fine.
      # Please refer "https://docs.pytest.org/en/latest/usage.html" for more options on running pytests from command line.
      - py.test tests/ --junit-xml $DEVICEFARM_LOG_DIR/junitreport.xml


  # 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
 

appiumlog.txt

 2021-08-31 21:36:54:156 - [debug] [35m[WD Proxy][39m Matched '/session' to command name 'createSession'
2021-08-31 21:36:54:157 - [debug] [35m[WD Proxy][39m Proxying [POST /session] to [POST http://127.0.0.1:8100/session] with body: {"capabilities":{"firstMatch":[{"bundleId":"com.liquidframeworks.app.FXTrucking","arguments":[],"environment":{},"eventloopIdleDelaySec":0,"shouldWaitForQuiescence":true,"shouldUseTestManagerForVisibilityDetection":false,"maxTypingFrequency":60,"shouldUseSingletonTestManager":true}],"alwaysMatch":{}}}
2021-08-31 21:40:54:187 - [35m[WD Proxy][39m Error: timeout of 240000ms exceeded
2021-08-31 21:40:54:188 - [35m[WD Proxy][39m     at createError (/usr/local/avm/versions/1.19.0/node_modules/appium/node_modules/axios/lib/core/createError.js:16:15)
2021-08-31 21:40:54:189 - [35m[WD Proxy][39m     at RedirectableRequest.handleRequestTimeout (/usr/local/avm/versions/1.19.0/node_modules/appium/node_modules/axios/lib/adapters/http.js:264:16)
2021-08-31 21:40:54:189 - [35m[WD Proxy][39m     at Object.onceWrapper (events.js:273:13)
2021-08-31 21:40:54:189 - [35m[WD Proxy][39m     at RedirectableRequest.emit (events.js:182:13)
2021-08-31 21:40:54:189 - [35m[WD Proxy][39m     at Timeout._onTimeout (/usr/local/avm/versions/1.19.0/node_modules/appium/node_modules/follow-redirects/index.js:166:13)
2021-08-31 21:40:54:189 - [35m[WD Proxy][39m     at ontimeout (timers.js:424:11)
2021-08-31 21:40:54:189 - [35m[WD Proxy][39m     at tryOnTimeout (timers.js:288:5)
2021-08-31 21:40:54:189 - [35m[WD Proxy][39m     at listOnTimeout (timers.js:251:5)
2021-08-31 21:40:54:189 - [35m[WD Proxy][39m     at Timer.processTimers (timers.js:211:10)
2021-08-31 21:40:54:209 - [debug] [35m[XCUITest][39m Failed to create WDA session (An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded). Retrying...
2021-08-31 21:40:55:235 - [debug] [35m[BaseDriver][39m Event 'wdaSessionAttempted' logged at 1630446055234 (14:40:55 GMT-0700 (Pacific Daylight Time))
2021-08-31 21:40:55:235 - [debug] [35m[XCUITest][39m Sending createSession command to WDA
2021-08-31 21:40:55:236 - [debug] [35m[WD Proxy][39m Matched '/session' to command name 'createSession'
2021-08-31 21:40:55:236 - [debug] [35m[WD Proxy][39m Proxying [POST /session] to [POST http://127.0.0.1:8100/session] with body: {"capabilities":{"firstMatch":[{"bundleId":"com.liquidframeworks.app.FXTrucking","arguments":[],"environment":{},"eventloopIdleDelaySec":0,"shouldWaitForQuiescence":true,"shouldUseTestManagerForVisibilityDetection":false,"maxTypingFrequency":60,"shouldUseSingletonTestManager":true}],"alwaysMatch":{}}}
2021-08-31 21:44:09:897 - [35m[WD Proxy][39m Got response with status 500: {"value":{"error":"session not created","message":"Failed to launch com.liquidframeworks.app.FXTrucking application","traceback":""},"sessionId":null}
2021-08-31 21:44:09:899 - [debug] [35m[W3C][39m Matched W3C error code 'session not created' to SessionNotCreatedError
2021-08-31 21:44:09:909 - [debug] [35m[XCUITest][39m Failed to create WDA session (A new session could not be created. Details: Failed to launch com.liquidframeworks.app.FXTrucking application). Retrying...
2021-08-31 21:44:10:918 - [debug] [35m[BaseDriver][39m Event 'wdaSessionAttempted' logged at 1630446250918 (14:44:10 GMT-0700 (Pacific Daylight Time))
2021-08-31 21:44:10:918 - [debug] [35m[XCUITest][39m Sending createSession command to WDA
2021-08-31 21:44:10:919 - [debug] [35m[WD Proxy][39m Matched '/session' to command name 'createSession'
2021-08-31 21:44:10:919 - [debug] [35m[WD Proxy][39m Proxying [POST /session] to [POST http://127.0.0.1:8100/session] with body: {"capabilities":{"firstMatch":[{"bundleId":"com.liquidframeworks.app.FXTrucking","arguments":[],"environment":{},"eventloopIdleDelaySec":0,"shouldWaitForQuiescence":true,"shouldUseTestManagerForVisibilityDetection":false,"maxTypingFrequency":60,"shouldUseSingletonTestManager":true}],"alwaysMatch":{}}}
2021-08-31 21:44:37:156 - [35m[HTTP][39m [37m<-- POST /wd/hub/session [39m[32m-[39m [90m- ms - -[39m
2021-08-31 21:44:37:157 - [35m[HTTP][39m [90m[39m
2021-08-31 21:44:37:158 - [35m[HTTP][39m Could not cache the response identified by 'f549e476-e1fe-4030-b874-224d6b4c1ae6', because it has not been completed
2021-08-31 21:44:37:158 - [35m[HTTP][39m Does the client terminate connections too early?
2021-08-31 21:44:37:182 - uncaughtException: Could not cache the response identified by 'f549e476-e1fe-4030-b874-224d6b4c1ae6', because it has not been completed
Error: Could not cache the response identified by 'f549e476-e1fe-4030-b874-224d6b4c1ae6', because it has not been completed
    at WriteStream.responseListener.once (/usr/local/avm/versions/1.19.0/node_modules/appium/node_modules/appium-base-driver/lib/express/idempotency.js:81:50)
    at Object.onceWrapper (events.js:273:13)
    at WriteStream.emit (events.js:182:13)
    at lazyFs.close (internal/fs/streams.js:208:14)
    at /usr/local/avm/versions/1.19.0/node_modules/appium/node_modules/graceful-fs/graceful-fs.js:61:14
    at FSReqWrap.oncomplete (fs.js:139:20)
2021-08-31 21:44:40:194 - [debug] [35m[BaseDriver][39m Performing cleanup of 1 cached application```
 

Комментарии:

1. Вы пробовали проверять файлы iOS .syslog в артефактах, которые они вам предоставляют? Это может быть проблемой с правами на подачу заявления.

2. @TobeE да, похоже, есть проблема с правом подачи заявки. Я добавляю файл .syslog

Ответ №1:

Как упоминал Тобе, по умолчанию AWS Device Farm удаляет приложения, загруженные на ее платформу, перед установкой их на устройства. Это приведет к получению прав Apple(https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AboutEntitlements.html) работать не так, как ожидалось. Если для правильной загрузки и тестирования вашего приложения требуются права Apple, мы рекомендуем оценить частные устройства, так как можно пропустить удаление приложения для частных устройств (https://docs.aws.amazon.com/devicefarm/latest/developerguide/skip-app-re-signing-on-private-devices.html#signing-apps-on-ios-devices). Свяжитесь с нами по адресу aws-devicefarm-support@amazon.com для получения более подробной информации.