Robot Framework - How to Connect to Amazon Device Farm

The Amazon device farm does not currently support the Robot platform with Appium. Is there any work or tool that can allow me to run my robot scripts on an Amazon device farm?

+5
source share
2 answers

AWS Device Farm supports environments such as Robotium, which have tools for recording and playback. If you want to use TestNG or JUnit, you can paste the language into your script that captures screenshots:

public boolean takeScreenshot(final String name) { String screenshotDirectory = System.getProperty("appium.screenshots.dir", System.getProperty("java.io.tmpdir", "")); File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); return screenshot.renameTo(new File(screenshotDirectory, String.format("%s.png", name))); } 

This is an important reporting feature. You can put this method on your abstract base or abstract test base.

0
source

Using a user environment , you can use the framework design of the robot. For example, here are the steps that I used to run a robotic design test in Device Farm.

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

Then I made changes to the resource file to run the device farm, referencing 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 

Then I created a test package to upload to Device Farm by doing the following:

 # 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 run tests in Device Farm.

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

0
source

Source: https://habr.com/ru/post/1268446/


All Articles