zoukankan      html  css  js  c++  java
  • HTMLTestRunner生成空白resault.html

    发现一奇葩问题,用idle或pyscripter执行脚本,生成的是空白html,通过cmd,进入脚本目录执行python xx.py,却能生成测试报告。

    HTMLTestRunner 例子

    #coding=utf-8
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support.ui import Select
    from selenium.common.exceptions import NoSuchElementException
    import unittest, time, re
    import HTMLTestRunner
    
    
    class My_Test_Suite(unittest.TestCase):
        u'''打印百度、google标题'''
        def setUp(self):
            self.driver = webdriver.Ie()
            self.driver.implicitly_wait(30)
            self.verificationErrors = []
            self.accept_next_alert = True
    
        def test_baidu(self):
            u'''打开百度'''
            driver = self.driver
            driver.get("http://www.baidu.com")
            print u'当前网页是:',driver.title
            driver.close()
    
        def test_google(self):
            u'''打开google'''
            driver = self.driver
            driver.get("http://www.google.com.hk")
            print u'当前网页是:',driver.title
    
        def tearDown(self):
            self.driver.quit()
            self.assertEqual([], self.verificationErrors)
    
    if __name__ == "__main__":
    
        #定义一个单元测试容器
        testunit=unittest.TestSuite()
    
        #将测试用例加入到测试容器中
        testunit.addTest(My_Test_Suite("test_baidu"))
        testunit.addTest(My_Test_Suite("test_google"))
    
        #定义个报告存放路径,支持相对路径
        filename = 'G:\seleniums\result.html'
    
        fp = file(filename, 'wb')
        #定义测试报告
        runner =HTMLTestRunner.HTMLTestRunner(stream=fp,title=u'测试报告',description=u'用例执行详情::')
    
        #运行测试用例
        runner.run(testunit)

  • 相关阅读:
    如何在DOS中枚举PCI设备
    [Color]深入学习YCbCr色彩模型
    [Imm]Imm API学习笔记——输入法属性
    VBE_INFO(获取VBE信息)
    用VB写高效的图像处理程序 V2.0(2006524)
    ANSI环境下支持多语言输入的单行文本编辑器 V0.01
    分析外星人计算Pi的程序
    位运算模块mBit.bas
    [FileFormat]用VB写的高速GIF、JPEG 编码/解码 程序
    ANTLR笔记3 ANTLRWorks
  • 原文地址:https://www.cnblogs.com/rmb-mylove123/p/3646900.html
Copyright © 2011-2022 走看看