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)
HTMLTestRunner生成空白resault.html的更多相关文章
- Python3和HTMLTestRunner生成html测试报告
1.测试环境: Python3.5+unittest+HTMLTestRunner 2.下载HTMLTestRunner.py文件 下载地址 http://tungwaiyip.info/softwa ...
- Python&Selenium借助HTMLTestRunner生成自动化测试报告
一.摘要 本篇博文介绍Python和Selenium进行自动化测试时,借助著名的HTMLTestRunner生成自动化测试报告 HTMLTestRunner.py百度很多,版本也很多,自行搜索下载放到 ...
- Python&Selenium借助html-testRunner生成自动化测试报告
一.摘要 本博文将介绍Python和Selenium进行自动化测试时,借助html-testRunner 生成自动化测试报告 安装命令:pip install html-testRunner 二.测试 ...
- Pycharm使用python3无法通过HTMLTestRunner生成测试报告《转载》
Pycharm使用python3无法通过HTMLTestRunner生成测试报告: https://blog.csdn.net/weixin_38981172/article/details/8238 ...
- 使用HTMLTestRunner生成报告
使用HTMLTestRunner生成报告 unittest本身并不具备这个功能,需要使用HTMLTestRunner库 使用步骤: 首先需要下载.py文件:http://tungwaiyip.info ...
- 转HTMLTestRunner 生成测试报告
1.HTMLTestRunner 是 Python 标准库的 unittest 模块的一个扩展.它生成易于使用的 HTML 测试报告 1>下载HTMLTestRunner.py文件,地址为: h ...
- Python+Selenium+Unittest+HTMLTestRunner生成测试报告+发送至邮箱,记一次完整的cnblog登录测试示例,
测试思路:单个测试集.单个测试汇成多个测试集.运行测试集.生成测试报告.发送至邮箱. 第一步:建立单个测试集,以cnblog登录为例. 测试用例: cnblog的登录测试,简单分下面几种情况:(1)用 ...
- Python 3+selenium+unittest+HTMLTestRunner生成测试报告
一.下载HTMLTestRunner.py,解压,将它放到 python安装路径的site-packages目录下 https://pan.baidu.com/s/1epWlibxbxWlNoIcxL ...
- Mac上实现Python用HTMLTestRunner生成html测试报告
一.导入HTMLTestRunnerNew文件 首先,我们要知道如果要利用HTMLTestRunnerNew生成测试报告的话,就需要对其进行导入: HTMLTestRunnerNew下载地址:链接:h ...
随机推荐
- in 与 = 的区别
in 与 = 的区别 结果是相同的.
- Java 之文件IO编程 之读取
package com.sun; /* * 这里是对文件IO流读取的操作 * 2014-08-10 */ import java.io.*; public class File_test { publ ...
- .NET设计模式(8):适配器模式(Adapter Pattern)
):适配器模式(Adapter Pattern) 适配器模式(Adapter Pattern) --.NET设计模式系列之八 Terrylee,2006年2月 概述 在软件系统中,由于应用环境的 ...
- rest例子
http://www.xdemo.org/spring-restful/(可用) http://www.open-open.com/lib/view/open1389075258125.html(有例 ...
- Java file文件的写入和读取及下载
File文件的写入 一.FileWriter 和BufferedWriter 结合写入文件 FileWriter是字符流写入字符到文件.默认情况下,它会使用新的内容代替文件原有的所有内容,但是,当指定 ...
- 一行代码实现headView弹簧拉伸效果
前言 很多app的个人中心上部的headView都实现了弹簧拉伸的效果,即tableView的top并不随着下拉而滑动,而是紧紧的停在屏幕的最上方. 我们今天就分析一下这个效果的实现方式. 分析 关键 ...
- GridView 编辑、删除 、分页
类似代码都差不多,记录一下,便于以后查看使用. 前台页面: <asp:GridView ID="gdvList" runat="server" AutoG ...
- 217. Contains Duplicate(C++)
217. Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your ...
- C++ xmmp IM开发笔记(一)
XMMP C++库采用 gloox (client) 下载地址:http://camaya.net/download/gloox-1.0.11.tar.bz2 glooxd (server) 下载地址 ...
- JS禁止横竖屏切换,强制横竖屏显示
js判断屏幕横竖屏: function orient() { //alert('gete'); if (window.orientation == 0 || window.orientation == ...