In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Python+Appium automation test case analysis", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Python+Appium automation test case analysis"!
I. Environmental preparation
1. Scripting language: Python3.x IDE: install Pycharm
two。 Install Java JDK, Android SDK
3.adb environment, path add E:SoftwareAndroid_SDKplatform-tools
4. Install Appium for windows, official website address http://appium.io/
Click the download button to go to the download page of GitHub, and select the corresponding platform for download.
After the installation is complete, start Appium,host and port by default, and then set up Android SDk and Java JDK
Then click the save and restart button below, and then click the first Start Server button, and you will see
2. Real machine testing
1. Connect to the mobile phone
Open the developer mode, connect the USB cable to the phone and the computer, and in the developer options, enable USB debugging
To test whether the connection is successful, execute the command adb devices
The above picture proves that the connection between the phone and the computer is successful.
two。 Click Start Inspector Session
Configure Desired Capabilities as follows
PlatformName: declare whether it is an ios or an Android system
PlatformVersion: Android kernel version number, which can be viewed by command adb shell getprop ro.build.version.release
DeviceName: the name of the connected device, which can be viewed by model in the command adb devices-l
Package name of the appPackage:apk
The launcherActivity of appActivity:apk can be viewed by adb shell dumpsys activity | findstr "mResume" (you need to open the mobile app first)
Note: adb shell dumpsys activity should be used before Android 8.1 | findstr "mFocus"
3. Run Start Session and select the element
There are three buttons in the Selected Element area on the right
Tap: executes the click event of the selected element
Send Keys: passing values for objects such as text boxes
If it is a text input element, clear the text
4. Recording script
The python code generated by recording is 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 Pythonfrom appium import webdrivercaps = {} caps ["platformName"] = "Android" caps ["platformVersion"] = "9.0.0" caps ["deviceName"] = "Mi_Note_3" caps ["appPackage"] = "com.antfortune.wealth" caps ["appActivity"] = "com.alipay.mobile.quinox.LauncherActivity" caps ["resetKeyboard"] = Truecaps ["unicodeKeyboard"] = Truedriver = webdriver.Remote ("http://localhost:4723/wd/hub", Caps) el1 = driver.find_element_by_id ("com.antfortune.wealth.login:id/login_main_button") el1.click () el2 = driver.find_element_by_id ("com.alipay.mobile.accountauthbiz:id/auth_login_btn") el2.click () driver.quit ()
5. Set up a project in pycharm to glue the code in, and before running, you need to install the pip install Appium-Python-Client dependency package through the pip command
Finally, remember a problem I encountered in these processes (now solved)
When running Start Session in Appium-desktop, the
Solution: in developer mode, open the usb debugging function and use emulation click, both of which need to be opened, and then run again at this time to solve the problem.
Thank you for your reading, the above is the content of "Python+Appium automated test case analysis". After the study of this article, I believe you have a deeper understanding of the problem of Python+Appium automated test case analysis, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.