首页 > 其他分享 >【3】有道云测试任务1-v1.0-v2.0-v3.0

【3】有道云测试任务1-v1.0-v2.0-v3.0

时间:2023-02-27 20:56:51浏览次数:55  
标签:__ v3.0 self yd v2.0 caps v1.0 remove install

 

 

 

 

work1_install_remove.py
#用面向对象的思想实现安装卸载的自动化测试V1.0
#导入appium类库
from appium.webdriver.webdriver import WebDriver
import time
import csv
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait

#定义测试安装卸载类
class yd_install_removeV1:
def __init__(self):
self.caps = {}
self.caps['automationName'] = 'UiAutomator2'
self.caps['platformName'] = 'Android'
self.caps['platformVersion'] = '6.0'
self.caps['deviceName'] = '192.168.141.101:5555'
self.caps['appPackage'] = 'com.android.launcher3'
self.caps['appActivity'] = '.Launcher t238'
self.driver = WebDriver('http://127.0.0.1:4723/wd/hub', self.caps)

def test_install_remove(self):

if self.driver.is_app_installed('com.youdao.note'):
self.driver.remove_app('com.youdao.note')
self.driver.install_app('E:\python\youdaoyun\youdaoyunbiji_84.apk')
#测试时确保appium,模拟器都打开
    def check_install(self):
# S1:安装后用程序启动有道云
self.caps['appPackage'] = 'com.youdao.note'
self.caps['appActivity'] = '.activity2.MainActivity t254'
self.driver = WebDriver('http://127.0.0.1:4723/wd/hub', self.caps)
# S2:弹出界面上抓取“拒绝”链接
# time.sleep(3)
# el = self.driver.find_element_by_id('com.android.packageinstaller:id/permission_deny_button').is_enabled()

el=WebDriverWait(self.driver,10).until(lambda x:x.find_element_by_id('com.android.packageinstaller:id/permission_deny_button'))
#print(el)
# S3:如果链接存在的,那么打印“安装成功”
# S4:否则打印安装失败
if el:
print("安装成功")
else:
print("安装失败")

if __name__ == '__main__':
#初始化类的对象
yd_install_remove_Obj=yd_install_removeV1()
#调用卸载安装
yd_install_remove_Obj.test_install_remove()
#调用检查安装
yd_install_remove_Obj.check_install()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 work1_install_remove2.py

#V2.0 实现两个模拟器设备安装卸载的兼容性测试
#导入appium类库
from appium.webdriver.webdriver import WebDriver
import time
#继承导入V1.0类
from youdaoproject.work1_install_remove import yd_install_removeV1

class yd_install_removeV2(yd_install_removeV1):
def __init__(self):
self.caps = {}
self.caps['automationName'] = 'UiAutomator2'
self.caps['platformName'] = 'Android'

def setdevice_6(self):
self.caps['platformVersion'] = '6.0'
self.caps['deviceName'] = '192.168.141.101:5555'
self.caps['appPackage'] = 'com.android.launcher3'
self.caps['appActivity'] = '.Launcher t238'
self.driver = WebDriver('http://127.0.0.1:4723/wd/hub', self.caps)

def setdevice_7(self):
self.caps['platformVersion'] = '7.1'
self.caps['deviceName'] = '192.168.141.102:5555'
self.caps['appPackage'] = 'com.android.launcher3'
self.caps['appActivity'] = '.Launcher t2'
self.driver = WebDriver('http://127.0.0.1:4723/wd/hub', self.caps)

if __name__ == '__main__':
yd_install_removeV2_obj=yd_install_removeV2()
#6.0版本的测试
yd_install_removeV2_obj.setdevice_6()
yd_install_removeV2_obj.test_install_remove()
yd_install_removeV2_obj.check_install()
#7.0版本的测试
yd_install_removeV2_obj.setdevice_7()
yd_install_removeV2_obj.test_install_remove()
yd_install_removeV2_obj.check_install()

 

 

 

 

work1_install_remove3.py

#V3.0 实现任意设备的兼容性测试
import csv
#导入appium类库
from appium.webdriver.webdriver import WebDriver
#导入V1.0相关内容
from youdaoproject.work1_install_remove import yd_install_removeV1

if __name__ == '__main__':
#实例化测试V1.0对象
yd_install_remove_Obj=yd_install_removeV1()

#从文件中读取相关的参数值

file = open("testpara.csv", "r")
tables = csv.reader(file)
yd_install_remove_Obj.caps = {}
yd_install_remove_Obj.caps['automationName'] = 'UiAutomator2'
yd_install_remove_Obj.caps['platformName'] = 'Android'
for rows in tables:
# print(rows[0])
# print(rows[1])
# print(rows[2])
# print(rows[3])
# print(rows[4])
# print(rows[5])

yd_install_remove_Obj.caps[rows[0]] = rows[1]
yd_install_remove_Obj.caps[rows[2]] = rows[3]
yd_install_remove_Obj.caps[rows[4]] = rows[5]
yd_install_remove_Obj.caps[rows[6]] = rows[7]

yd_install_remove_Obj.driver = WebDriver('http://127.0.0.1:4723/wd/hub', yd_install_remove_Obj.caps)
yd_install_remove_Obj.test_install_remove()
yd_install_remove_Obj.check_install()



标签:__,v3.0,self,yd,v2.0,caps,v1.0,remove,install
From: https://www.cnblogs.com/zhangyideyl/p/17157688.html

相关文章