Robot Framework - How to connect to Amazon Device Farm - mobile

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?

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

AWS Device Farm supports frameworks like Robotium that have record and playback scripting tools. If you wish to use TestNG or JUnit You can insert language into your script that captures screen shots:
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 feature for reporting. You can put this method on your Abstract BasePage or Abstract TestBase.

Related

Build app in AppCenter that uses Carthage

I've inherited a project that builds with Carthage. Using Xcode 12, I was faced with this error:
fatal error: /Applications/Xcode_12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Intermediates.noindex/ArchiveIntermediates/AEXML iOS/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AEXML.framework/AEXML and /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Products/Release-iphonesimulator/AEXML.framework/AEXML have the same architectures (arm64) and can't be in the same fat output file
Building universal frameworks with common architectures is not possible. The device and simulator slices for "AEXML" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.
Quick Google search brought me to this which works for my local machine.
Using AppCenter for the first time, I created a Pre-Build script with the following:
#!/usr/bin/env bash
# Pre-build
# See: https://learn.microsoft.com/en-us/appcenter/build/custom/scripts/#pre-build
echo "Pre-build has started."
sh ./carthage.sh update --use-submodules
echo "Pre-build has ended."
I assume Carthage should be used to build this? I get the error in AppCenter:
*** Building scheme "AEXML iOS" in AEXML.xcodeproj
A shell task (/usr/bin/xcrun lipo -create /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Intermediates.noindex/ArchiveIntermediates/AEXML\ iOS/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AEXML.framework/AEXML /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Products/Release-iphonesimulator/AEXML.framework/AEXML -output /Users/runner/work/1/s/Carthage/Build/iOS/AEXML.framework/AEXML) failed with exit code 1:
fatal error: /Applications/Xcode_12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Intermediates.noindex/ArchiveIntermediates/AEXML iOS/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AEXML.framework/AEXML and /Users/runner/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/AEXML/4.6.0/Build/Products/Release-iphonesimulator/AEXML.framework/AEXML have the same architectures (arm64) and can't be in the same fat output file
Building universal frameworks with common architectures is not possible. The device and simulator slices for "AEXML" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.
How to build in AppCenter?
--use-xcframeworks
This option is only available from Carthage 0.37.0. The appcenter's carthage version is 0.36.0. They need to update the carthage used in appcenter projects.
Can you look at the logs and see if this script is being run? Or is it that appcenter is running the carthage binary?
EDIT
The good news is that appcenter identifies carthage 0.37.0! I added a appcenter-post-clone.sh in my project directory:
#!/usr/bin/env bash
set -e
set -x
carthage update --cache-builds --use-xcframeworks --platform ios
carthage version
echo "" > Cartfile
echo "" > Cartfile.resolved
appcenter recognises that --use-xcframeworks is used and therefore 0.37.0 is required.
NOTE: I'm emptying the Cartfile* so that appcenter doesn't run its native carthage command (which it does on noticing Cartfile and Cartfile.resolved).
EDIT 2
I'm now considering using something like carthage_cache in appcenter as the carthage checkout and build ends up taking a lot of time.
Try this one (you may need to upgrade your Carthage first)
carthage update --no-use-binaries --use-xcframeworks --platform iOS

Can I automate vm instance setup with Multipass?

I'm using multipass to setup an Ubuntu virtual machine image. I'd like to make the installation of apt packages repeatable. Is it possible to script this somehow?
You could create a cloud-config file and add it via --cloud-init option when launching a fresh VM. Cloud init lets you provision a VM on almost any cloud provider, it's a very versatile tool. That way you can add any package you want, create news users, run bash commands etc. .
More on cloud-config files here.
You then run a cloud-config file with:
multipass launch -n your_vm_name --cloud-init path/to/cloudconfig/file.yaml

How to debug a Windows kernel driver properly?

I'm trying to set up the environment of Windows VM for debugging a kernel driver.
I created a sample of kernel driver in Visual Studio 2017. File->New Project->Kernel Mode Driver (basic project; just for testing - autogenerated trace macro, required procedures, etc.) and want to test it on the target machine.
There are my steps (target machine):
Install Windows 10 to a virtual machine (VirtualBox);
Turn on Test mode and set BCDEdit as local;
Install WDK;
Download OSR Loader;
Copy files after a building to a VM (C:\DriverTest\TestKernelDriver2\; .cer, .inf, .pdb, .sys);
Create traces folder; C:\DriverTest\TestKernelDriver2\traces\
Install the cerificate - TestKernelDriver2.sys; (Sign mode: Test Sign)
Run OSR Driver Loader, choose the driver, press Register service (Success).
Run tracelog with params (GUID was generated by templates; no via Tools->Create GUID) - success:
tracelog -start TestKernelDriver2 -guid #0f4fbb98-1569-495b-88d1-f654b1e2d68e -f C:\DriverTest\TestKernelDriver2\traces\trace.etl -flag 2 -level 0xFFFF
Check C:\DriverTest\TestKernelDriver2\traces\trace.etl; (exist - 64KB size)
OSR Driver Loader: press Start Service (fail). Error message: The specified procedure could not be found.
Stop tracelog - success:
tracelog -stop TestKernelDriver2
Open Event Viewer. Windows logs->System. The last error:
The TestKernelDriver2 service failed to start due to the following error:
The specified procedure could not be found.
Details:
EventData
param1 TestKernelDriver2
param2 %%127
54006500730074004B00650072006E0065006C0044007200690076006500720032000000
Open C:\DriverTest\TestKernelDriver2\traces\trace.etl via Event Viewer and don't see any logs.
How can I find out what is procedure was missed?
I tried to investigate it via Dependency Walker and revealed that some .sys files are missed (WppRecorder.sys, WdfLdr.sys, msrpc.sys, EXT-MS-WIN-###.DLL). These filed are located in C:\Windows\System32\drivers. I copied the files to C:\Windows\System32 and Dependency Walker calmed down. What about EXT-MS-WIN-*.DLL - I read in this topic that these files can be missed.
Thanks to #magicandre1981. I installed my driver via PnPUtil. But now, I see it in the list of pnputil /enum-drivers command.
But when I run the following commands in WinDbg, I don't see my driver in the list:
!load wdfkd.dll
!wdfkd.wdfldr
I'm trying to make steps of Session 1 from this Microsoft ttutoriall.
I found the solution via tracefmt generator and TraceView application.
Step 0: Generate tmf file by command:
tracefmt С:\TestDriver\TestKernelDriver2\TestKernelDriver2.etl -i С:\TestDriver\TestKernelDriver2\TestKernelDriver2.sys -r С:\TestDriver\TestKernelDriver2\TestKernelDriver2 -p С:\TestDriver\TestKernelDriver2\tmfs -o С:\TestDriver\TestKernelDriver2\TestKernelDriver2.txt -v
Step 1: Create Session in TraceView:
File -> Create New Session. Fill Manually Entered Control GUID. (0f4fbb98-1569-495b-88d1-f654b1e2d68e)
Step 2: Choose Source of WPP Format Information (Set TMF Search Path option) and fill path: C:\DriverTest\TestKernelDriver2\tmfs
Step 3: Next, fill Log Session Name and Real-Time Display is checked. Finish.

Matlab integration - Run and test Matlab VOLTTRON Integration - pyzmq error+ volltron/config. path

Below the steps followed to integrate a fake building - fake modbus device (Ubuntu 16.04 LTS) with matlab-based interface.
Following the documentation steps at: http://volttron.readthedocs.io/en/4.1/devguides/walkthroughs/DrivenMatlabAgent-Walkthrough.html
Installation steps for system running Matlab:
Install python (my Python versions: 3.6.3 and 2.7.12)
Install pyzmq following the steps at (https://github.com/zeromq/pyzmq): I use pip install pyzmq
I get
Requirement already satisfied: pyzmq in ./env/local/lib/python2.7/site-packages
Steps for system running Matlab:
Install python – done
Install pyzmq –done
Install Matlab-- done (R2017b)
run pyversion --done
version: '2.7'
executable: '/home/USER_NAME/volttron/env/bin/python'
library: 'libpython2.7.so.1.0'
home: '/home/USER_NAME/volttron/env'
isloaded: 0
when I run py.zmq.pyzmq_version() I get
ans =
Python str with no properties.
15.4.0
I copied the example.m to the desktop.
Run and test Matlab VOLTTRON Integration:
To run and test the integration:
Assumptions
Device driver agent is already developed (master_driveragent-3.1.1- is installed)
Installation:
Install VOLTTRON –done
Add subtree volttron-applications under volttron/applications by using the following command –
For adding subtree: I used the code:
git subtree add --prefix applications https://github.com/VOLTTRON/volttron- applications.git develop --squash
error
(Working tree has modifications. Cannot add.)
Configuration
Copy example configuration file applications/pnnl/DrivenMatlabAgent/config_waterheater to volltron/config. (I could not find a path called config?)
Questions
Please is there any issue in pyzmq ?
In the volttron root I run the subtree command, why it is not accepting to add the subtree?
What is the volltron/config. path?
Thanks,
Looks like you have you have local changes in your cloned volttron directory. Please stash or commit those changes before adding subtree.
If config folder does not exists you can create it (I will make a note of it in the documentation as well) It is only a location to copy the config file to make changes ( config_url and data_url )

What are dronekit-python dependencies?

The dronekit Getting Started page suggests installing WinPython to use dronekit-Python on Windows because it includes the dependencies. I already have a working Python installation and I prefer not to risk messing it up with WinPython. What are the dependencies I need to install?
As of DKPY 2.0 this is outdated. Also, I might move to making a MavProxy module depending on whether or not the unpaid devs decide to stay when 3DR stops funding Dronekit
I've written a procedure to help with this problem which I've pasted. 3DR claims they're going to fix it, but in the mean time I hope this will help.
This setup is for Windows 64-bit systems only, although similar procedures will work with 32-bit.
Install MAVProxy and run it once before reaching step 5.
Install Notepad++.
Install Python v2.7.
Inside the Python folder, run WinPython Control Panel and select Advanced->Register Python.
Inside the same folder, run WinPython Command Prompt and input the following four commands:
• pip uninstall python-dateutil
• pip install droneapi
• pip install console
• echo module load droneapi.module.api >> %HOMEPATH%\AppData\Local\MAVProxy\mavinit.scr
Install WX Python. It should be the 64-bit Python 2.7 version.
Download and install OpenCV 2.4.11 to any folder
• Copy/paste the file cv2.pyd from OpenCV\build\python\2.7\x64\ to \python-2.7.6.amd64\Lib\site-packages.
Steps 8 through 11 apply to SITL only
Follow the online documentation for setting up Cygwin for SITL in Windows
Go to C:\cygwin\home\Your Username\ardupilot\Tools\autotest\
Open sim_vehicle.sh in Notepad++
• Change line 429 from…
cygstart -w "/cygdrive/c/Program Files (x86)/MAVProxy/mavproxy.exe" $options --cmd="$extra_cmd" $*
to...
cygstart -w "/cygdrive/c/Users/YOUR USERNAME HERE/Desktop/WinPython-64bit-2.7.6.4/python-2.7.6.amd64/Dronekit/Scripts/mavproxy.py" $options --cmd="$extra_cmd" $*
Note: This location changes depending on where you installed WinPython. For me, it was the desktop.
Start simulations as you would normally for SITL. To run Python scripts during the simulations, use the command
• api start Path to script\script_name
To use the code to connect to an actual copter, open WinPython Command Prompt
• Navigate to the folder which contains the scripts you wish to test
• Type mavproxy.py --master=”com##”,57600
• Run your script by typing into the MAVProxy terminal
o api start script_name

Resources