# -*-coding:utf-8-*-
# !/usr/bin/python
import uiautomator2 as u2
import public.common as common
import public.const as const
import public.system as system
__author__ = 'Administrator'
'''
@Project: pythonProject_baidu
@File : test_toast.py
@Time : 2022/1/3 15:36
@Author : Administrator
#=====================================#
@TestCase_Title:
@Level:
@Precondition:
@Step:
@Result:
#=====================================#
'''
def setup():
print("前置条件")
def test_step():
print("执行步骤")
#打开百度APP,进入内容详情页,长按
d(text="复制").click()
assert '内容已复制' in d.toast.get_message(5.0,defalt='no toast'),'无toast提示'
#或者
assert d.toast.get_message(5.0,defalt='no toast')=='内容已复制','无toast提示'
#校验下一个toast时,上一个toast虽然消失,但是缓存可能还在,需要清除toast缓存
d.toast.reset()
d(text="剪切").click()
assert '内容已剪切' in d.toast.get_message(5.0, defalt='no toast'), '无toast提示'
def teardown():
print("后置方法")
if __name__ == "__main__":
d = u2.connect(common.sn)
try:
setup()
test_step()
except Exception as e:
common.screenshot("err")
raise e
finally:
teardown()
1、python自动化项目---toast校验
于 2022-01-03 16:06:33 首次发布