class baidu:
def __init__(self,d):
page_list=d.shell("pm list packages").output
page_all=page_list.split()
for pags in page_all:
if pags.find("BaiduMap")!=-1:
self.package_name=pags.split(":",1)[1]
# print(self.package_name)
# -*-coding:utf-8-*-
# !/usr/bin/python
import uiautomator2 as u2
import public.common as common
import public.const as const
import public.system as system
__author__ = 'Administrator'
'''
@Project: pythonProject_baidu
@File : get_pagename.py
@Time : 2022/1/3 17:01
@Author : Administrator
#=====================================#
@TestCase_Title:
@Level:
@Precondition:
@Step:
@Result:
#=====================================#
'''
def setup():
print("前置条件")
def test_step():
print("执行步骤")
name=const.baidu(d).package_name
print(name)
def teardown():
print("后置方法")
if __name__ == "__main__":
d = u2.connect(common.sn)
try:
setup()
test_step()
except Exception as e:
common.screenshot("err")
raise e
finally:
teardown()
输出:
D:\Python3.7\python.exe D:/pythonProject_baidu/scripts/get_pagename.py
前置条件
执行步骤
com.baidu.BaiduMap
后置方法
Process finished with exit code 0