Environment Construction: Python2.7+uiautomator+android+windows + PIL

Source: Internet
Author: User

Background: Build an automated UI test environment for Android

Project Use framework:

Https://github.com/xiaocong/uiautomator (Author blog: http://xiaocong.github.io/)

Machine: Windows 64-bit

Major problems encountered:

1. Project using Python 2.7, native installed Python 3.5,pycharm install plugin, show PIP version is incorrect

2. Python 2.7 Installs the image, relies on Django, installs the process to report IOError

3. Windows Python 2.7 installation image, relying on installation pillow, error Pip-build-sl1urw\pillow failed with error code 1, give a hint link

4. The Python command line executes the basic command in Uiautomator, D.info or D (text="Settings"). Click (), no response

5. Run the JSONRCP server on Android device gradlew cc process card in > Building 96% >: app:connecteddebugandroidtest

Issue One: The project uses Python 2.7, the native has installed the Python 3.5,pycharm installation plugin, showing the PIP version is incorrect

Pycharm using native default Python version, modify the native environment variable path, specify the installation address of Python 2.7;

Install directly using the command line, pycharm corresponding to the Python configuration will be able to see the corresponding installed package (interpreter corresponding to Python) after the installation is successful.

Py-2-m pip install Uiautimator

Question two: Python 2.7 installs image, relies on Django, installs the process to report IOError

Web search, Django package also exists and the Python version of compatibility issues, the default installation of 2.0 is not applicable to Python 2.7, the installation needs to specify the version number, specific to the https://pypi.python.org/pypi/Django/2.0

Execute command

Py-2-m pip install django==1.11.6

Issue three: Windows 2.7 Python installation image, relying on installation pillow, error Pip-build-sl1urw\pillow failed with error code 1, give a hint link

The specific error is as follows:

Tips in the link:

Do not confirm if there is an installation PiL, try to delete PiL

Py-2-m pip uninstall PIL   # show not installed PIL

Understand the project use, the colleague clear, need is pil,image not must, instead installs the PIL

PIL official website (http://www.pythonware.com/products/pil/) Download Python 2.7 for EXE, execute, error no Python 2.7, command line execution Python, version has distinguished from Python 2.7 [ Thank you: http://blog.csdn.net/boycycyzero/article/details/42647161]

Verifying the use of the pillow, the image recognition infrastructure is successfully installed.

Question four: The Python command line executes the basic command in Uiautomator, D.info or D (text="Settings"). Click (), unresponsive, raise IOError ("RPC Server Not started!")

Run the project file, the phone is not responding, directly use the Uiautomator command, D.info after a long time no response, kill the process without any information, need to wait, there is an error message raise IOError ("RPC Server not started!")

Git has a corresponding FAQ (after the error message to search, or to wait, do not respond to the urgent process):

Question five: 5. Run the JSONRCP server on Android device gradlew cc process card in > Building 96% >: app:connecteddebugandroidtest

After downloading Https://github.com/xiaocong/android-uiautomator-server#build source, unzip into the directory, execute

Stuck in the third step

Online already has ISSUE:HTTPS://GITHUB.COM/XIAOCONG/ANDROID-UIAUTOMATOR-SERVER/ISSUES/11

Workaround: Https://github.com/xiaocong/android-uiautomator-server/wiki/Force-Start-Json-Server

Note that Gradlew CC would get stuck at 96% or so, the server has started. Go and try it in Python, everything should is working.

Although stuck, it's actually up.

Execute step Fourth and Uiautomator command directly

ADB forward TCP:9008 tcp:9008

Python

>>> from Uiautomator import device as D
>>> D.info

Output results

Perfect ~

Environment Construction: Python2.7+uiautomator+android+windows + PIL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.