1.非po模型实现模拟器登录qq
2.使用po模型实现qq登录
class BasePages:
def __init__(self,driver):
self.driver = driver
#元素定位
def locator(self,*loc):
return self.driver.find_element(*loc)
#清空
def clear(self,*loc):
self.locator(*loc).clear()
#输入
def input(self,test,*loc):
self.locator(*loc).send_keys(test)
#点击
def click(self,*loc):
self.locator(*loc).click()
#滑动(上下左右滑动)
def swipe(self,start_x,start_y,end_x,end_y,duration=0):
#获取屏幕的尺寸
window_size = self.driver.get_window_size()
x = window_size["width"]
y = window_size["height"]
self.driver.swipe(start_x=x*start_x,
start_y=y*start_y,
end_x= x*end_x,
end_y=y*end_y,
duration=duration)
from lz.base.basepage import BasePages
from appium.webdriver.common.mobileby import MobileBy
class daohang(BasePages):
def __init__(self, driver):
BasePages.__init__(self, driver)
def click_dl(self):
self.click(MobileBy.ID,"com.tencent.mobileqq:id/btn_login")
from lz.base.basepage import BasePages
from appium.webdriver.common.mobileby import MobileBy
class denglu(BasePages):
def __init__(self, driver):
BasePages.__init__(self, driver)
#清空账号
def clean_zh(self):
self.clear(MobileBy.ACCESSIBILITY_ID,"请输入QQ号码或手机或邮箱")
#输入账号
def shuru_zh(self,test):
self.input(test,MobileBy.ACCESSIBILITY_ID,"请输入QQ号码或手机或邮箱")
#清空密码
def clean_mm(self):
self.clear(MobileBy.ACCESSIBILITY_ID, "密码 安全")
# 输入密码
def shuru_mm(self,test):
self.input(test,MobileBy.ACCESSIBILITY_ID, "密码 安全")
#点击登录按钮
def dl(self):
self.click(MobileBy.ACCESSIBILITY_ID,"登 录")
#同意相关协议
def ty(self):
self.click(MobileBy.ACCESSIBILITY_ID, "同意")
# 再次点击登录按钮
def dl2(self):
self.click(MobileBy.ACCESSIBILITY_ID, "登 录")
3.使用pytest 实现qq登录
4.引入yaml文件
5.数据驱动
6.pytest生成测试报告
7.unittest生成测试报告
导入htmltestrunner
创建testhtml.py文件