I. Environmental preparation
1. Scripting language: IDE: install Pycharm
2. Install Java JDK, Android SDK
environment, path add E:\Software\Android_SDK\platform-tools
4. Install Appium for windows, official website address/
Click the download button to go to the GitHub download page, select the corresponding platform to download the
After the installation is complete, start Appium with the host and port defaults, and then set up the Android SDk and Java JDK.
Then tap the Save and Restart button at the bottom, and then tap the first Start Server button, and you'll see the
Second, the real machine test
1. Connect the cell phone
Turn on Developer Mode, connect your phone to your computer with a USB cable, and turn on USB debugging in the Developer Options.
To test if the connection is successful, execute the command adb devices
The above picture proves that the phone and computer are connected successfully.
2. Click Start Inspector Session.
Configure Desired Capabilities as follows
platformName: Declare whether it is an iOS or Android system.
platformVersion: Android kernel version number, can be viewed by the command adb shell getprop
deviceName: the name of the connected device, viewed by the command adb devices -l in model
appPackage: package name of the apk
appActivity: apk's launcherActivity, viewed by command adb shell dumpsys activity | findstr "mResume" (need to open the phone app first)
Note: Before Android 8.1 you should use adb shell dumpsys activity | findstr "mFocus"
3. Run Start Session, select the element
The Selected Element area on the right has three buttons
Tap: executes the click event of the selected element Send Keys: passes a value for an object such as a text box If it is a text input element, clear the text
4. Recording Scripts
Record the generated python code as follows:
# This sample code uses the Appium python client # pip install Appium-Python-Client # Then you can paste this into a file and simply run with Python from appium import webdriver caps = {} caps["platformName"] = "Android" caps["platformVersion"] = "9.0.0" caps["deviceName"] = "Mi_Note_3" caps["appPackage"] = "" caps["appActivity"] = "" caps["resetKeyboard"] = True caps["unicodeKeyboard"] = True driver = ("http://localhost:4723/wd/hub", caps) el1 = driver.find_element_by_id(":id/login_main_button") () el2 = driver.find_element_by_id(":id/auth_login_btn") () ()
5. create a project in pycharm to paste the code, in the run before, but also through the pip command to install pip install Appium-Python-Client dependent packages
Finally, a note about a problem I had with these processes (now resolved)
When running Start Session in Appium-desktop, the
Solution:In developer mode, open the usb debugging function and use analog click, both should be opened, and then re-run at this time, can be solved!
To this article on the use of Python Appium automated testing steps to this article, more related Python Appium automated testing content please search for my previous articles or continue to browse the following related articles I hope you will support me in the future!