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


    下载 

     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不选会出问题。

    测试结果

  • 相关阅读:
    Tomcat配置JNDI
    (转)通过反编译深入理解Java String及intern
    (转)Java8内存模型-永久代(PermGen)和元空间(Metaspace)
    排序算法
    并发编程
    MySQL
    Go语言
    Go语言
    Go语言
    Go语言
  • 原文地址:https://www.cnblogs.com/congxueda/p/7357250.html
Copyright © 2020-2023  润新知