gpt4 book ai didi

mobile - Robot Framework - 如何连接到 Amazon Device Farm

转载 作者:行者123 更新时间:2023-12-02 09:34:46 24 4
gpt4 key购买 nike

目前 Amazon 设备场不支持 Appium 的机器人框架。是否有解决方法或工具可以让我在亚马逊设备场上运行我的机器人脚本?

最佳答案

使用custom environment可以使用机器人框架。例如,以下是我在 Device Farm 中运行 robotsframework 测试所用的步骤。

git clone https://github.com/serhatbolsu/robotframework-appiumlibrary.git
cd robotframework-appiumlibrary

接下来,我通过引用 environment variables 对 Device Farm 执行的资源文件进行了修改.

./demo/test_android_contact_resource.txt

*** Settings ***
Library AppiumLibrary

*** Variables ***
${REMOTE_URL} http://localhost:4723/wd/hub
${PLATFORM_NAME} %{DEVICEFARM_DEVICE_PLATFORM_NAME}
${DEVICE_NAME} %{DEVICEFARM_DEVICE_NAME}
${APP} %{DEVICEFARM_APP_PATH}

*** Keywords ***
add new contact
[Arguments] ${contact_name} ${contact_phone} ${contact_email}
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME} deviceName=${DEVICE_NAME} app=${APP} automationName=UIAutomator2
Click Element accessibility_id=Add Contact
Input Text id=com.example.android.contactmanager:id/contactNameEditText ${contact_name}
Input Text id=com.example.android.contactmanager:id/contactPhoneEditText ${contact_phone}
Input Text id=com.example.android.contactmanager:id/contactEmailEditText ${contact_email}
Click Element accessibility_id=Save

然后,我使用以下步骤创建了要上传到 Device Farm 的测试包:


# assumes we're still in the same directory as local execution
# create a virtual directory
/usr/local/bin/python2 /Users/$(whoami)/Library/Python/2.7/lib/python/site-packages/virtualenv.py workspace
cd workspace/
source bin/activate
pip install pytest
pip install Appium-Python-Client
pip install robotframework
pip install robotframework-appiumlibrary
mkdir tests
cp ../demo/*.txt ./tests/
pip freeze > requirements.txt
pip wheel --wheel-dir wheelhouse -r requirements.txt
echo "# This is a dummy file to appease the parser in Device Farm" > ./tests/dummy_test.py
# mv command might be required on mac to appease the Device Farm parser
mv wheelhouse/scandir-1.10.0-cp27-cp27m-macosx_10_12_x86_64.whl wheelhouse/scandir-1.10.0-py2.py3-none-any.whl
# changed ./bin/robot to use #!/bin/python instead of absolute path to workspace
zip -r test_bundle.zip tests/ wheelhouse/ requirements.txt

接下来我在 testspec.yml 中使用了以下命令文件以在 Device Farm 中执行测试。

bin/robot --outputdir $DEVICEFARM_LOG_DIR/robotresultstests/test_android_contacts.txt

关于mobile - Robot Framework - 如何连接到 Amazon Device Farm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44312734/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com