AndroidViewClient-Culebra-Tutorial-Android-UI-Automation

How to Install, Setup and Use AndroidViewClient on Windows

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:


Posted

in

by

Comments

22 responses to “How to Install, Setup and Use AndroidViewClient on Windows”

  1. swati Avatar
    swati

    Hii Darpan can you please explain me how to use threading on androidviewclient

    1. Darpan Dodiya Avatar

      Sorry I haven’t been keeping up with AndroidViewClient lately.

  2. brr Avatar
    brr

    thank you bro
    Just a typo.
    easy_install.exe –upgrade androidviewclient (X)
    easy_install.exe -–upgrade androidviewclient (O)

  3. Pranshu Ranjan Avatar
    Pranshu Ranjan

    Hey! Darpan Bhaiya , I have one query that I have python 3.6.6 installed and i want to integrate AndroidViewClient with python script that supports only python 3.x versions so is there any fork or way i can make use of AndroidViewClient along my script with python 3.6.6 version . Thanks !
    And you’re blog posts are awesome!

    1. Darpan Dodiya Avatar

      Hey buddy! Thanks for your kind words.

      Unfortunately, I haven’t used AndroidViewClient in a while. I am afraid I don’t have answer to your question.

  4. Rivers Cuomo Avatar
    Rivers Cuomo

    Thanks Darpan! Before I could install AndroidViewClient at step 6, I had to pip install numpy and matplotlib.

    1. Darpan Dodiya Avatar

      Oh thanks for note! I will update this post to reflect this.

  5. letroll Avatar

    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

  6. nitin Avatar
    nitin

    Spot on Darpan!

    Cheers!

  7. jauntyjas Avatar
    jauntyjas

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

    1. Darpan Dodiya Avatar

      Hello,

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

  8. Avdhoot Bhosale Avatar
    Avdhoot Bhosale

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

    1. Darpan Dodiya Avatar

      Happy to help! 🙂

  9. luhaigen Avatar
    luhaigen

    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

    1. Darpan Dodiya Avatar

      Hi!

      Its hard to guess whats going wrong here.

      Were you able to go through 1-5 successfully?

      1. luhaigen Avatar
        luhaigen

        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.

        1. Darpan Dodiya Avatar

          Great!!

          Have fun! 🙂

    2. binh Avatar
      binh

      Same problem

  10. Alex Avatar
    Alex

    Thanks Darpan!

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

Leave a Reply

Your email address will not be published. Required fields are marked *