How to get platformVersion, deviceName, appPackage
This article mainly explains "how to get platformVersion, deviceName, appPackage". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to get platformVersion, deviceName, appPackage".
The command is obtained as follows:
Connect the mobile phone to the computer
Devicename: adb devices
Platformversion: adb shell getprop ro.build.version.release
AppPackage: aapt dump badging installation package address
AppActivity: open appk and enter the command
Adb shell "dumpsys window | grep mCurrentFocus"
The code is obtained as follows:
#-*-coding: utf-8-*-
From appium import webdriver
# filter device id using regular expressions
Import re
# using the time.sleep (xx) function to wait
From time import sleep
# using os module to invoke commands
Import os
# path and package name of the package tested
AppLocation = "C:\ Users\\ Administrator\\ Desktop\\ xxxx_151.apk"
# read device id
Read_DeviceId = list (os.popen ('adb devices'). Readlines ())
'' execute the cmd command to save the result as a list read_DeviceId''
Print read_DeviceId
Device_Id=read_DeviceId [1] .split ('\ t') [0]
Take the second item in the list, split the string, and take the first item in the sliced list
There is a problem here. If multiple devices are connected, you can only deal with the first one.
See here that regular implementations are available?
''
Print device_Id
# read the device system version number
Device_Android_Version = list (os.popen ('adb shell getprop ro.build.version.release'). Readlines ())
Print device_Android_Version
Device_Version=device_Android_Version [0] .split ('\ r\ n') [0]
Print device_Version
# read package information of APK
AppPackageAdb = list (os.popen ('aapt dump badging' + appLocation) .readlines ())
AppPackage = re.findall (r'\ 'com\ winter.shipping?\', appPackageAdb [0]) [0]
Print appPackage
Thank you for reading, the above is "how to get platformVersion, deviceName, appPackage" content, after the study of this article, I believe you have a deeper understanding of how to obtain platformVersion, deviceName, appPackage this problem, the specific use of the situation also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!