另外后续的一些触屏的操作、元素判断也可以按需放在这里面:
def is_element(self, element):
source = self.driver.page_source
if element in source:
return True
else:
return False
def drag(self, bx=0.50, bw=0.05, by=0.4, bz=0.9):
x = self.driver.get_window_size()['width']
y = self.driver.get_window_size()['height']
sx = x * bx
ex = x * bw
sy = y * by
ey = y * bz
return self.driver.swipe(sx, sy, ex, ey, 1000)
if __name__ == "__main__":
with open(result_path, 'wb') as fp:
runner = HTMLTestReportCN.HTMLTestRunner(stream=fp, title='自动化APP测试报告',
description='基于自动化APP测试框架产生的测试报告')
runner.run(test_suit())