Step by step tutorial on setting up AndroidViewClient on Windows machines.
AndroidViewClient is a python library and tools that simplifies test script creation and android test automation, providing higher level operations and the ability of obtaining the tree of Views present at any given moment on the device or emulator screen and perform operations on it.
AndroidViewClient is commonly used to create tests scripts but can be in stand-alone scripts as well. Test script creation can be even further simplified and automated by using Culebra.
Culebra is a sweet tool!
AndroidViewClient on GitHub: https://github.com/dtmilano/AndroidViewClient
When I decided to learn and use AndroidViewClient, it took me a day to figure how to utilize it. Mostly because I was newbie to Python language and didn’t know much about the setup tools.
After a bit of hands on, now I feel AndroidViewClient is fairly easy to employ.
Tutorial for Setting up AndroidViewClient on Windows
1. Download and install Python 2.7.
Download link: https://www.python.org/downloads/
Note: AndroidViewClient doesn’t support Python 3.x versions. Download the Python 2.7.11 installer.
2. Setup system environment variables.
Right Click on Computer > Properties.
From the left pane, Click on, Advanced System Settings.
Environment Variables > Path > Edit > Append in Variable value, C:\Python27;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk
(Change C:\Python27 path as per your installation directory of Python.)
3. Open Windows command prompt and type >python
It shall show Python shell running.
If you get an error like, ‘python’ is not recognized as an internal or external command, operable program or batch file., you might have missed something from Step 1, 2.
4. Install setuptools
You need to have setuptools installed in order to download and use AndroidViewClient library from PyPi.
Go to: https://bootstrap.pypa.io/ez_setup.py
Right Click > Save as > Save file on Desktop.
Open your Desktop > Shift + Right Click > Open command window here > Run: >python ez_setup.py
If the installation is successful, you’ll see:
5. Verify installation of setuptools.
Go to your Python installation folder e.g. C:\Python27 and you’ll see a new folder named Scripts.
6. Run easy_install
Go to that Scripts folder, open command prompt (Shift + Right Click) and run: >easy_install.exe --upgrade androidviewclient
This will search PyPI (Python Package Index) for AndroidViewClient, download and install it. Of course, it goes without saying that you will require internet connection.
7. Verify installation of AndroidViewClient
Go to: C:\Python27\Lib\site-packages
You shall see a folder named, androidviewclient-11.5.1-py2.7.egg. Implying the installation has been successful.
8. Download zip file from GitHub.
Go to: https://github.com/dtmilano/AndroidViewClient/archive/master.zip, download and extract the zip file.
9. Go to extracted folder, go to examples folder and run check-import.py
cmd: >python check-import.py
It shall output “OK”
If not, you made some error setting up AndroidViewClient properly. Try to re-follow aforementioned tutorial steps carefully.
If you’ve made so far, congrats! You’ve successfully setup AndroidViewClient on your system and you’re ready to use it.
Tutorial for culebra and dump.
10. Run culebra / dump tools
Go to, extracted zip folder/tools. You’ll see two files, culebra and dump. They are very handy tools in script generation.
Use them via,
cmd: >python culebra
cmd: >python dump
Detailed usage and documentation can be found at:
Culebra – https://github.com/dtmilano/AndroidViewClient/wiki/culebra
Culebra GUI – https://github.com/dtmilano/AndroidViewClient/wiki/Culebra-GUI
Dump – https://github.com/dtmilano/AndroidViewClient/wiki/dump
11. Install pillow
In order to run culebra GUI, you’ll get error of PIL package. In that case,
Refer to step 7, and run: >easy_install.exe --upgrade pillow
Extras
12. ADB installation
Make sure you’ve ADB installed on your machine. If you’re unsure or haven’t installed it yet,
Head over to: http://forum.xda-developers.com/showthread.php?p=48915118
Download 15 Seconds ADB Installer and run it. It shall set up adb correctly on your machine.
13. adb version error
If you get adb version error while running culebra or dump, pass -E as argument.
cmd: >python culebra -E
-E stands for Ignore ADB version check
While running from script: ignoreversioncheck’: True
14. UIAutomator
AndroidViewClient internally uses uiautomator. If you’ve Android SDK installed on your machine,
Find uiautomator at: <location of your sdk>/tools/uiautomatorviewer.bat
Another way to take uiautomator dump is: >adb shell uiautomator dump
This will take dump and store it in window_dump.xml file on device. File location will be inside root folder of storage space. (Mostly, /sdcard/window_dump.xml)
Let me know if I’ve missed something! 🙂
Related Posts:
Leave a Reply