概述
主要区别:
'app': 'C:\Users\del\Desktop\b\jsq.apk',
安装了就不需要路径,没有安装就需要路径
一、系统未按装待测app
# C:Usersdel>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:Usersdel>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不同配置的全部内容,希望文章能够帮你解决APP——自动化——python——系统未按装待测app和已经按装待测app不同配置所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复