移动测试之appium+python 导出报告
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了移动测试之appium+python 导出报告相关的知识,希望对你有一定的参考价值。
下载
test.py
from appium import webdriver import time import unittest import HTMLTestRunner class SearchCls(unittest.TestCase): def setUp(self): desired_caps = { ‘platformName‘: ‘Android‘, ‘deviceName‘: ‘Galaxy Note4‘, ‘platformVersion‘: ‘5.1.1‘, ‘appPackage‘: ‘com.baidu.searchbox‘, ‘appActivity‘: ‘MainActivity‘, ‘unicodeKeyboard‘: True, ‘resetKeyboard‘: True } self.driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘, desired_caps) def search_info(self): driver = self.driver driver.find_element_by_id("com.baidu.searchbox:id/baidu_searchbox").click() driver.find_element_by_id("com.baidu.searchbox:id/SearchTextInput").clear() driver.find_element_by_id("com.baidu.searchbox:id/SearchTextInput").send_keys(‘appium test‘) driver.find_element_by_id("float_search_or_cancel").click() time.sleep(2) driver.find_element_by_id("com.baidu.searchbox:id/redtip_icon").click() time.sleep(2) driver.find_element_by_id("com.baidu.searchbox:id/common_menu_item_icon").click() def search_two(self): driver = self.driver driver.find_element_by_id("com.baidu.searchbox:id/baidu_searchbox").click() driver.find_element_by_id("com.baidu.searchbox:id/SearchTextInput").clear() driver.find_element_by_id("com.baidu.searchbox:id/SearchTextInput").send_keys(‘HTML5‘) driver.find_element_by_id("float_search_or_cancel").click() if __name__ == ‘__main__‘: suite = unittest.TestSuite() suite.addTest(SearchCls(‘search_two‘)) suite.addTest(SearchCls(‘search_info‘)) filename = ‘E:\\\\testTool\\\\pyFile\\\\app.html‘ fb = open(filename, ‘wb‘) runner = HTMLTestRunner.HTMLTestRunner(stream=fb, title=‘search‘, description=‘search‘) runner.run(suite) fb.close()
这个要勾选,在测试多个case不选会出问题。
测试结果
以上是关于移动测试之appium+python 导出报告的主要内容,如果未能解决你的问题,请参考以下文章
Appium python自动化测试系列之使用HTMLTestRunner生成测试报告(十三)