Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Robot Framework - How to connect to Amazon Device Farm

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?

like image 881
blin92 Avatar asked Jun 01 '17 16:06

blin92


People also ask

How do I use AWS device farm for testing?

Sign in to the Device Farm console at https://console.aws.amazon.com/devicefarm . In the navigation pane, choose Mobile Device Testing, and then choose Projects. If you already have a project, you can upload your tests to it. Otherwise, choose New project, enter a Project Name, and then choose Create.

How does AWS Device Farm work?

Device Farm is an app testing service that you can use to test and interact with your Android, iOS, and web apps on real, physical phones and tablets that are hosted by Amazon Web Services (AWS). There are two main ways to use Device Farm: Automated testing of apps using a variety of testing frameworks.

What is remote access in AWS device Farm?

Remote access allows you to swipe, gesture, and interact with a device through your web browser in real time to test functionality and reproduce customer issues. You interact with a specific device by creating a remote access session with that device.


1 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

like image 120
jmp Avatar answered Sep 27 '22 22:09

jmp