AndroidViewClient-Culebra-Tutorial-Android-UI-Automation
Code

How to Install, Setup and Use AndroidViewClient on Windows

on
August 21, 2018

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

1 - Setting up Environment Variables - AndroidViewClient Tutorial

 

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.

2 - Type command python in Windows command prompt - AndroidViewClient Tutorial

 

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:

3 - After successful installation of setuptools - AndroidViewClient Tutorial

 

5. Verify installation of setuptools. 

Go to your Python installation folder e.g. C:\Python27 and you’ll see a new folder named Scripts.

4 - Scripts folder - AndroidViewClient Tutorial

 

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.

5 - easy_install.exe --upgrade androidviewclient - AndroidViewClient Tutorial

 

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.

6 - AndroidViewClient folder after extraction - AndroidViewClient Tutorial

 

9. Go to extracted folder, go to examples folder and run check-import.py

cmd: >python check-import.py

It shall output “OK

8 - Run check-import file - AndroidViewClient Tutorial

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

7 - UI Automator Viewer - AndroidViewClient Tutorial

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:

TAGS
RELATED POSTS
14 Comments
  1. Reply

    letroll

    November 3, 2017

    Hello, first thank you for your tutorial. I’m begin with it, fetch ez_setup.py, open it to read-it…
    (not stupid ๐Ÿ˜‰ ) And I see : https://github.com/pypa/setuptools/issues/581 just to inform you

  2. Reply

    nitin

    March 28, 2017

    Spot on Darpan!

    Cheers!

    • Reply

      Darpan Dodiya

      March 31, 2017

      Yo! Cheers!

  3. Reply

    jauntyjas

    March 27, 2017

    Hi Darpan
    It doesn’t seem to be able to download androidviewclient for me. I have tried it many times but in vain. Please suggest something.

    C:\Python27\Scripts>easy_install.exe –upgrade androidviewclient
    Searching for androidviewclient
    Reading https://pypi.python.org/simple/androidviewclient/
    Download error on https://pypi.python.org/simple/androidviewclient/: timed out — Some packages may not be found!
    Couldn’t find index page for ‘androidviewclient’ (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading https://pypi.python.org/simple/
    Download error on https://pypi.python.org/simple/: timed out — Some packages may not be found!
    No local packages or working download links found for androidviewclient
    error: Could not find suitable distribution for Requirement.parse(‘androidviewclient’)

    • Reply

      Darpan Dodiya

      March 31, 2017

      Hello,

      Looks like a temporary network issue to me. Would you mind giving it one more shot?

  4. Reply

    Avdhoot Bhosale

    November 30, 2016

    Very good tutorial…!! Thanks a lot Darpan ..

    • Reply

      Darpan Dodiya

      November 30, 2016

      Happy to help! ๐Ÿ™‚

  5. Reply

    luhaigen

    October 9, 2016

    Thanks Darpan!But I have a problem,in the step 6,can’t run easy_install.It shalls “ImportError:No module named extern”.How can I fix it?Thanks

    • Reply

      Darpan Dodiya

      October 13, 2016

      Hi!

      Its hard to guess whats going wrong here.

      Were you able to go through 1-5 successfully?

      • Reply

        luhaigen

        November 16, 2016

        Hi!
        I have solved the problem,before the step 6,we should run command”pip.exe install -U setuptools”under the Scripts floder,and then run command”pip๏ผšpython -m pip install –upgrade pip”under the Scripts floder,after doing these,I can go through the rest of steps successfully.

        • Reply

          Darpan Dodiya

          November 16, 2016

          Great!!

          Have fun! ๐Ÿ™‚

    • Reply

      binh

      October 23, 2016

      Same problem

  6. Reply

    Alex

    April 21, 2016

    Thanks Darpan!

    Tutorial steps are precise and it worked very well for me.

    • Reply

      Darpan Dodiya

      April 29, 2016

      Cheers!

LEAVE A COMMENT

Darpan Dodiya
Raleigh, NC, USA

Hi! I'm Darpan. 23 yr old ex-Software Engineer, now pursuing Master's in Computer Science at NC State, USA. This is my personal blog to share my interests in travelling, photography, programming and life. Glad to see you here, have a look around the website, you'll enjoy. Drop a comment or reach out to me or get connected via links below. Have a good day! :)

Lookup
Subscribe to Newsletter
Topics
Subscribe YouTube Channel
Work Together

Are you an individual, business, organization, tourism agency or government department? We can work together.

We can work with content creation, photoshoot, event photography, cinematic video production, web/software development, digital marketing, documentary, short film.

Let’s discuss. Contact details can be found here.

Ads & Promotion

Please visit the advertisement page for details regarding advertisements, campaigns, guest posts and promotions.