Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to open app and click on mobile phone with python?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article Xiaobian introduces in detail for you "python how to open the mobile phone app and click the operation", the content is detailed, the steps are clear, the details are handled properly, I hope that this "python how to open the mobile phone app and click on the operation" article can help you solve your doubts, the following follow the editor's ideas slowly in depth, together to learn new knowledge.

Part 1: open the application step 1: install Android SDK

(1) download

Platform-tools

(2) add environment variables

Extract the downloaded package file and try not to contain Chinese characters in the path.

Right-click on my computer-> Properties-> Advanced system Settings-> Environment variables-> Select Path--Edit-> New-> enter the decompression path of the first step-> confirm all the way.

Open the cmd window, type adb version, and the installation is successful as follows

Step 2: debug your phone and connect to your computer

(1) use USB cable to connect the computer to the mobile phone

(2) Modulation and development mode of mobile phone

You can view it in "Settings"-"developer options"-"Android debugging".

If the developer option is not found in the settings, click "version number" 7 times in "Settings"-"about Mobile phone"

(3) turn on the USB to debug

You can go to "system and updates"-"developer options"-"USB debugging"

(4) verify whether the connection is successful

Open the cmd window

Enter adb devices, and the connection is successful as follows

Step 3: find the application portal, the top priority, and decide whether it can continue in the future.

(1) use the adb command to get all installed app package names

Adb shell pm list packages.package:com.huawei.lbspackage:com.android.bluetoothpackage:com.android.providers.contactspackage:com.netease.cloudmusicpackage:tv.danmaku.bili # as test data package:com.android.captiveportalloginpackage:com.huawei.audioaccessorymanagerpackage:com.huawei.hiactionpackage:com.huawei.trustedthingsauthpackage:com.eg.android.AlipayGphonepackage:com.huawei.android.airsharingpackage:cn.wps.moffice_engpackage:com.free.playerpackage:com.huawei.rcsserviceapplicationpackage:com.huawei.ohos.famanager.

(2) get the startup entry of an application package name

Adb shell dumpsys package tv.danmaku.bili | findstr activity5106328 tv.danmaku.bili/com.alibaba.cloudgame.joystick.ui.activity.JoystickGroupActivity filter 51a3fc3 step 4: launch the application adb shell am start-n tv.danmaku.bili/com.alibaba.cloudgame.joystick.ui.activity.JoystickGroupActivity part 2: app element location step 1: install uiautomator2

Google carries out the Python version of UI automated testing tool uiautomator, which is similar to the browser F12 where you can find the location of UI elements according to ID, and make corresponding gestures to simulate human operation.

Pip install-- pre-U uiautomator2 step 2: install atx-agent on your phone

First, the device is connected to PC, and the device can be found by adb devices (refer to the installation steps of the adb tool). After installation, a yellow car ATX app will appear on the phone.

Python-m uiautomator2 init step 3: install the control positioning tool to help us get the controls on the screen

Quickly locate element coordinates for Android and iOS native applications, automatically generate code and click to run

Pip install-- if pre weditor# reports an error, directly specify the lower version to install pip install weditor==0.6.4 step 4: start weditor

The application will set up a service locally, listen to port 17310, automatically open a browser window, project our phones to the window, and write code directly on the right.

Python-m weditorC:\ Users\ fatpuffer > python-m weditorlistening on http://192.168.0.108:17310[I 220414 21:08:22 web:2246] 304 GET / (: 1) 9.37ms [I 220414 21:08:24 web:2246] 304 GET / cdn.jsdelivr.net/bootstrap/3.3.7/css/bootstrap.min.css (:: 1) 1389.65ms [I 220414 21:08:24 web:2246] 304 GET / unpkg.com/element-ui/lib/theme -chalk/index.css (:: 1) 6.68ms [I 220414 21:08:24 web:2246] 304 GET / static/libs/css/buttons.css (:: 1) 5.98ms [I 220414 21:08:24 web:2246] 304 GET / static/libs/fontawesome/css/font-awesome.min.css (:: 1) 5.99ms [I 220414 21:08:24 web:2246] 304 GET / cdn.jsdelivr.net/bootstrap.select/1.12.2/css/bootstrap-select .min.css (:: 1) 7.98ms [I 220414 21:08:24 web:2246] 304 GET / cdn.jsdelivr.net/npm/jstree@3.3.8/dist/themes/default/style.min.css (:: 1) 8.96ms

Step 5: learn uiautomator2 syntax, achieve app automatic click to read here, this "python how to open the phone app and click on the operation" article has been introduced, want to master the knowledge of this article also need to practice to understand, if you want to know more about the content of the article, welcome to pay attention to the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report