Robot Framework - How to connect to Amazon Device Farm

Viewed 2563

Currently Amazon device farm does not have support for Robot framework with Appium. Is there a work around or a tool that can allow me to run my robot scripts on Amazon device farm?

2 Answers

Using the custom environment it is possible to use the robotframework. For example, here are the steps I used to run a robotframework test in Device Farm.

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

Next I made modifications to the resource file for the Device Farm execution by referencing the environment variables.

./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

I then created the test package to upload to Device Farm using the following steps:


# 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

Next I used the following command in the testspec.yml file to execute the tests in Device Farm.

bin/robot --outputdir $DEVICEFARM_LOG_DIR/robotresults tests/test_android_contacts.txt

Related