码迷,mamicode.com
首页 > 移动开发 > 详细

APP——自动化——python——系统未按装待测app和已经按装待测app不同配置

时间:2020-06-25 17:56:52      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:inux   user   text   apk   api   lin   java   int   esc   

 

主要区别:  

            ‘app‘: ‘C:\\Users\\del\\Desktop\\b\\jsq.apk‘,

安装了就不需要路径,没有安装就需要路径

 

技术图片

 

 

 

 

 

一、系统未按装待测app

 

#      C:\Users\del>adb shell dumpsys window w |findstr \/ |findstr name=
#      mSurface=Surface(name=com.youba.calculate/com.youba.calculate.MainActivity)            #adb命令查看包名和启动activity

#com.youba.calculate:id/btn_plus  +
#com.youba.calculate:id/btn_equal  =

from appium import webdriver
import  time

desired_caps = {
    platformName: Android,             #待测试手机的系统

deviceName:8DF6R17503000072, #使用手机或模拟器的类型

platformVersion: 8.0.0, #待测手机系统版本

"unicodeKeyboard":"true", #支持中文输入,会自动安装unicode输入法,默认是false

"resetKeyboard":"true", #如果设置了中文输入为true,此设置为自动化退出后,重置输入法到原来状态

app: C:\\Users\\del\\Desktop\\b\\jsq.apk, #手机未按照待测app时,设置安装路径、包名、启动activity appPackage: com.youba.calculate, appActivity: com.youba.calculate.MainActivity, } driver = webdriver.Remote(http://127.0.0.1:4723/wd/hub, desired_caps) time.sleep(5) driver.find_element_by_id("com.youba.calculate:id/btn_one").click(); # 1+2= time.sleep(5) driver.find_element_by_id("com.youba.calculate:id/btn_plus").click(); time.sleep(5) driver.find_element_by_id("com.youba.calculate:id/btn_two").click(); time.sleep(5) driver.find_element_by_id("com.youba.calculate:id/btn_equal").click(); time.sleep(5) print(driver.find_element_by_id("com.youba.calculate:id/tv_display").text); print("#------------------------------------------------------------------------------------") print("#------------------------------------------------------------------------------------") print(driver.current_package) print(-------------------------) print(driver.current_activity) print(-------------------------) print(driver.capabilities) print(-------------------------) driver.quit()

 

 

执行结果:

 

3
#------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------
com.youba.calculate
-------------------------
.MainActivity
-------------------------
{‘platform‘: ‘LINUX‘, ‘webStorageEnabled‘: False, ‘takesScreenshot‘: True, ‘javascriptEnabled‘: True, ‘databaseEnabled‘: False, ‘networkConnectionEnabled‘: True, ‘locationContextEnabled‘: False, ‘warnings‘: {}, ‘desired‘: {‘platformName‘: ‘Android‘, ‘deviceName‘: ‘8DF6R17503000072‘, ‘platformVersion‘: ‘8.0.0‘, ‘unicodeKeyboard‘: True, ‘resetKeyboard‘: True, ‘app‘: ‘C:\\Users\\del\\Desktop\\b\\jsq.apk‘, ‘appPackage‘: ‘com.youba.calculate‘, ‘appActivity‘: ‘com.youba.calculate.MainActivity‘}, ‘platformName‘: ‘Android‘, ‘deviceName‘: ‘8DF6R17503000072‘, ‘platformVersion‘: ‘8.0.0‘, ‘unicodeKeyboard‘: True, ‘resetKeyboard‘: True, ‘app‘: ‘C:\\Users\\del\\Desktop\\b\\jsq.apk‘, ‘appPackage‘: ‘com.youba.calculate‘, ‘appActivity‘: ‘com.youba.calculate.MainActivity‘, ‘deviceUDID‘: ‘8DF6R17503000072‘, ‘deviceApiLevel‘: 26, ‘deviceScreenSize‘: ‘1440x2560‘, ‘deviceScreenDensity‘: 560, ‘deviceModel‘: ‘EDI-AL10‘, ‘deviceManufacturer‘: ‘HUAWEI‘, ‘pixelRatio‘: 3.5, ‘statBarHeight‘: 84, ‘viewportRect‘: {‘left‘: 0, ‘top‘: 84, ‘width‘: 1440, ‘height‘: 2344}}
-------------------------

 

 

 

 

 

=======================================================================================================

=======================================================================================================

 

 

 

 

二、系统已经按装待测app不同配置

 

#      C:\Users\del>adb shell dumpsys window w |findstr \/ |findstr name=
#      mSurface=Surface(name=com.youba.calculate/com.youba.calculate.MainActivity)            #adb命令查看包名和启动activity

#com.youba.calculate:id/btn_plus  +
#com.youba.calculate:id/btn_equal  =

from appium import webdriver
import  time

desired_caps = {
platformName: Android, #待测试手机的系统

deviceName:8DF6R17503000072, #使用手机或模拟器的类型

platformVersion: 8.0.0, #待测手机系统版本

"unicodeKeyboard":"true", #支持中文输入,会自动安装unicode输入法,默认是false

"resetKeyboard":"true", #如果设置了中文输入为true,此设置为自动化退出后,重置输入法到原来状态

#‘app‘: ‘C:\\Users\\del\\Desktop\\b\\jsq.apk‘, #手机未按照待测app时,设置安装路径、包名、启动activity

appPackage: com.youba.calculate, appActivity: com.youba.calculate.MainActivity, } driver = webdriver.Remote(http://127.0.0.1:4723/wd/hub, desired_caps) time.sleep(5) driver.find_element_by_id("com.youba.calculate:id/btn_one").click(); # 1+2= time.sleep(5) driver.find_element_by_id("com.youba.calculate:id/btn_plus").click(); time.sleep(5) driver.find_element_by_id("com.youba.calculate:id/btn_two").click(); time.sleep(5) driver.find_element_by_id("com.youba.calculate:id/btn_equal").click(); time.sleep(5) print(driver.find_element_by_id("com.youba.calculate:id/tv_display").text); print("#------------------------------------------------------------------------------------") print("#------------------------------------------------------------------------------------") print(driver.current_package) print(-------------------------) print(driver.current_activity) print(-------------------------) print(driver.capabilities) print(-------------------------) driver.quit()

 

 

执行结果:

 

3
#------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------
com.youba.calculate
-------------------------
.MainActivity
-------------------------
{‘platform‘: ‘LINUX‘, ‘webStorageEnabled‘: False, ‘takesScreenshot‘: True, ‘javascriptEnabled‘: True, ‘databaseEnabled‘: False, ‘networkConnectionEnabled‘: True, ‘locationContextEnabled‘: False, ‘warnings‘: {}, ‘desired‘: {‘platformName‘: ‘Android‘, ‘deviceName‘: ‘8DF6R17503000072‘, ‘platformVersion‘: ‘8.0.0‘, ‘unicodeKeyboard‘: True, ‘resetKeyboard‘: True, ‘appPackage‘: ‘com.youba.calculate‘, ‘appActivity‘: ‘com.youba.calculate.MainActivity‘}, ‘platformName‘: ‘Android‘, ‘deviceName‘: ‘8DF6R17503000072‘, ‘platformVersion‘: ‘8.0.0‘, ‘unicodeKeyboard‘: True, ‘resetKeyboard‘: True, ‘appPackage‘: ‘com.youba.calculate‘, ‘appActivity‘: ‘com.youba.calculate.MainActivity‘, ‘deviceUDID‘: ‘8DF6R17503000072‘, ‘deviceApiLevel‘: 26, ‘deviceScreenSize‘: ‘1440x2560‘, ‘deviceScreenDensity‘: 560, ‘deviceModel‘: ‘EDI-AL10‘, ‘deviceManufacturer‘: ‘HUAWEI‘, ‘pixelRatio‘: 3.5, ‘statBarHeight‘: 84, ‘viewportRect‘: {‘left‘: 0, ‘top‘: 84, ‘width‘: 1440, ‘height‘: 2344}}
-------------------------

 

APP——自动化——python——系统未按装待测app和已经按装待测app不同配置

标签:inux   user   text   apk   api   lin   java   int   esc   

原文地址:https://www.cnblogs.com/xiaobaibailongma/p/13192139.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!