码迷,mamicode.com
首页 > 移动开发 > 详细

移动测试之appium+python 导出报告(六)

时间:2017-08-14 14:27:31      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:color   sts   bsp   ase   board   images   glob   box   runner   

下载 

 HTMLTestRunner.py

python3可以参考这个地址

 

这是针对Python2.7版本

 

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 导出报告(六)

标签:color   sts   bsp   ase   board   images   glob   box   runner   

原文地址:http://www.cnblogs.com/congxueda/p/7357250.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!