发现一奇葩问题,用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)

HTMLTestRunner生成空白resault.html的更多相关文章

  1. Python3和HTMLTestRunner生成html测试报告

    1.测试环境: Python3.5+unittest+HTMLTestRunner 2.下载HTMLTestRunner.py文件 下载地址 http://tungwaiyip.info/softwa ...

  2. Python&Selenium借助HTMLTestRunner生成自动化测试报告

    一.摘要 本篇博文介绍Python和Selenium进行自动化测试时,借助著名的HTMLTestRunner生成自动化测试报告 HTMLTestRunner.py百度很多,版本也很多,自行搜索下载放到 ...

  3. Python&Selenium借助html-testRunner生成自动化测试报告

    一.摘要 本博文将介绍Python和Selenium进行自动化测试时,借助html-testRunner 生成自动化测试报告 安装命令:pip install html-testRunner 二.测试 ...

  4. Pycharm使用python3无法通过HTMLTestRunner生成测试报告《转载》

    Pycharm使用python3无法通过HTMLTestRunner生成测试报告: https://blog.csdn.net/weixin_38981172/article/details/8238 ...

  5. 使用HTMLTestRunner生成报告

    使用HTMLTestRunner生成报告 unittest本身并不具备这个功能,需要使用HTMLTestRunner库 使用步骤: 首先需要下载.py文件:http://tungwaiyip.info ...

  6. 转HTMLTestRunner 生成测试报告

    1.HTMLTestRunner 是 Python 标准库的 unittest 模块的一个扩展.它生成易于使用的 HTML 测试报告 1>下载HTMLTestRunner.py文件,地址为: h ...

  7. Python+Selenium+Unittest+HTMLTestRunner生成测试报告+发送至邮箱,记一次完整的cnblog登录测试示例,

    测试思路:单个测试集.单个测试汇成多个测试集.运行测试集.生成测试报告.发送至邮箱. 第一步:建立单个测试集,以cnblog登录为例. 测试用例: cnblog的登录测试,简单分下面几种情况:(1)用 ...

  8. Python 3+selenium+unittest+HTMLTestRunner生成测试报告

    一.下载HTMLTestRunner.py,解压,将它放到 python安装路径的site-packages目录下 https://pan.baidu.com/s/1epWlibxbxWlNoIcxL ...

  9. Mac上实现Python用HTMLTestRunner生成html测试报告

    一.导入HTMLTestRunnerNew文件 首先,我们要知道如果要利用HTMLTestRunnerNew生成测试报告的话,就需要对其进行导入: HTMLTestRunnerNew下载地址:链接:h ...

随机推荐

  1. C++话题

    1.多态地实现 A:C++中多态的实现原理是怎样的? Q:通过迟邦定技术(late binding)实现. 具体实现原理如下: 1. 基类中函数带virtual关键字,表示该方法为虚函数. 2. 子类 ...

  2. python基础知识十

    特殊的方法 在类中有一些特殊的方法具有特殊的意义,比如__init__和__del__方法,它们的重要性我们已经学习过了. 一般说来,特殊的方法都被用来模仿某个行为.例如,如果你想要为你的类使用x[k ...

  3. EventBus3 简单使用及注意点

    博客: 安卓之家 微博: 追风917 CSDN: 蒋朋的家 简书: 追风917 # EventBus3 简介 EventBus Android 发布/订阅事件总线,可简化 Activities, Fr ...

  4. SQL Server 表字段值转列名 示例

    前几天,同事问我怎样把字段值转换成字段列,就写了一个最简单的Demo分享一下. 代码如下: -- 创建测试表以及添加测试数据create table #temp(a money,b varchar(1 ...

  5. 分享一个在PearOS里面的plank的配置文件

    plank的配置文件的路径是/home/pear/.config/plank/dock1/settings #This file auto-generated by Plank. #2013-09-0 ...

  6. 线性回顾-generalize issue

    Ein的平均,Eout的平均 用这个平均来justify linear regresssion能够用的很好 noise level 资料里有多少的杂讯 等一下要证明的事情 predictions + ...

  7. 343. Integer Break -- Avota

    问题描述: Given a positive integer n, break it into the sum of at least two positive integers and maximi ...

  8. JAVA_HOME 的设置

    1. 永久修改,对所有用户有效(不建议这么使用,对Oracle 等用户都有影响) # vi /etc/profile export JAVA_HOME=/usr/local/jdk1.8.0_20/e ...

  9. linux安装composer

    1,确保php已成功安装,并且php可以被访问php -r "copy('https://getcomposer.org/installer', 'composer-setup.php'); ...

  10. SurfaceFlinger服务概述和学习计划

    SurfaceFlinger服务负责绘制Android应用程序的UI 实现相当复杂,要从正面分析它的实现不是一件容易的事.既然不能从正面分析,我们就想办法从侧面分析.说到底,无论SurfaceFlin ...