This is mainly used for Android automation, the underlying call adb command to drive android devices

Environmental installation

Adb installation

Brew Cask install Android-platform-tools verify: ADB Devices

UIAutomator2 installation

Input: pip3 install uiautomator2 -i https://pypi.douban.com/simple

3. Weditor installation

Enter: python3 -m PIP install weditor Use: python3 -m weditor

After input, the terminal will automatically open the default browser, and you will see the following interface (USB connection to the mobile phone is required, and USB debugging has started in mobile development mode), at which time you can locate APP elements

Precautions ✨

Mac Switch to the default Python version
  1. If python3 is not available on the Mac, type:brew install python3
  2. To switch the system’s default Python, enter:vi ~/.bash_profile
Alias python2 = '/ System/Library/Frameworks/Python framework Versions / 2.7 / bin/python2.7' alias Python3 = '/ usr/local/Cellar/[email protected]/3.9.0 _1 / Frameworks/Python framework Versions / 3.9 / bin/python3.9' alias python=python3Copy the code
  1. Effect:source ~/.bash_profile
  2. Validation:python --version
Python3: No module named ‘weditor

Sudo pip3 install Weditor: No module named ‘weditor’

Python3 -m PIP install weditor

Problem solving ✌️

Mac executes the source ~/.bash_profile environment variable each time to take effect

The environment variables are configured in ~/. Bash_profile, but the configuration does not take effect after each terminal restart. You need to run source ~/. Bash_profile again.

Solution: Add source ~/.bash_profile at the end of the ~/.zshrc file

Problem solving ✌️

Refer to the link

Error: No module named ‘selenium’ in python/UIautomator2 Mac- Executes the source ~/.bash_profile environment variable each time to take effect