ios - 在 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 阶段设置了与 default-capabilities 相同的设置。
推荐阅读
- linux - 每次监视执行时都有不同的文件间接寻址
- json - 如何用 jq 命令替换 JSON 值?
- angular - 在反应式表单上使用正则表达式进行 Angular 7 电子邮件验证
- python-3.x - 从其他功能更改条目小部件值
- amazon-ec2 - Rancher 卡在等待 SSH 可用
- windows - Azure 上的 git 不要求我输入密码,推送失败
- javascript - 在 Mozilla Firefox 中使用 toLocaleDateString 函数无法获取正确的日期时间格式
- django - 您正在尝试添加没有默认值的不可空字段库存
- c# - 如何使用 1 个递归函数 (c-sharp) 反转字符串中的单词
- python - 创建一个函数,它接受一个浮点数作为输入并返回一个包含数字的字符串