设为首页 加入收藏

TOP

Appium基于Python unittest自动化测试 & 自动化测试框架 -- PO并生成html测试报告(二)
2017-12-23 06:06:50 】 浏览:345
Tags:Appium 基于 Python unittest 自动化 测试 框架 生成 html 报告
.1:4723/wd/hub
',desired_caps) 24 time.sleep(5) 25 self.verificationErrors = "今天天气不错在家学习!" 26 27 def tearDown(self): 28 time.sleep(10) 29 self.driver.quit() 30 31 def test_saveedittext(self): 32 """保存编辑的文本""" 33 sp = CreatPage(self.driver) 34 sp.add_button_link() 35 sp.run_case("今天天气不错在家学习!") 36 #断言:实际结果,预期结果,错误信息 37 self.assertEqual(sp.get_finish_button_text(),self.verificationErrors,msg="验证失败!")

creat_page.py

 1 from appiumframework.PO import base_page
 2 import time
 3 
 4 class CreatPage(base_page.Action):
 5     add_button_loc = ("com.smartisan.notes:id/add_button")
 6     edittext_loc = ("com.smartisan.notes:id/list_rtf_view")
 7     finish_button_loc = ("com.smartisan.notes:id/send_finish_button")
 8 
 9     def add_button_link(self):
10         self.find_element(self.add_button_loc).click()
11         time.sleep(3)           #等待3秒,等待登录弹窗加载完成
12 
13     def run_case(self,value):
14         self.find_element(self.edittext_loc).send_keys(value)
15         time.sleep(5)
16         self.find_element(self.finish_button_loc).click()
17         time.sleep(2)
18 
19     def get_finish_button_text(self):
20         return self.find_element(self.edittext_loc).text

base_page.py

 1 class Action(object):
 2     #初始化
 3     def __init__(self,se_driver):
 4         self.driver = se_driver
 5 
 6     #重写元素定位的方法
 7     def find_element(self,loc):
 8         try:
 9             return self.driver.find_element_by_id(loc)
10         except Exception as e:
11             print("未找到%s"%(self,loc))

测试报告截图:

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇生日提醒 下一篇每天一点爬虫(一)

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目