【selenium】HTMLTestRunner测试报告生成
__author__ = 'Administrator'
#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 #引入 HTMLTestRunner 包
class Baidu (unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://www.baidu.com/"
self.verificationErrors = []
self.accept_next_alert = True
def test_baidu_search(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_id("kw").send_keys("")
driver.find_element_by_id("su").click()
time.sleep(2)
driver.close()
#百度设置用例
def test_baidu_set(self):
driver = self.driver
#进入搜索设置页
driver.get(self.base_url + "/gaoji/preferences.html")
#设置每页搜索结果为 100 条
driver.implicitly_wait(30)
m=driver.find_element_by_xpath(".//*[@id='gxsz']/tbody/tr[4]/td[2]/select")
m.find_element_by_xpath("//option[@value='50']").click()
time.sleep(5)
#保存设置的信息
driver.find_element_by_xpath(".//*[@id='gxszButton']/input[1]").click()
time.sleep(2)
driver.switch_to_alert().accept()
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
#定义一个单元测试容器
testunit=unittest.TestSuite()
#将测试用例加入到测试容器中
testunit.addTest(Baidu("test_baidu_search"))
testunit.addTest(Baidu("test_baidu_set"))
#定义个报告存放路径,支持相对路径
filename = 'D:\\report\\result.html'
fp = file(filename, 'wb')
#定义测试报告
runner =HTMLTestRunner.HTMLTestRunner(
stream=fp,
title=u'百度搜索测试报告',
description=u'用例执行情况:')
#运行测试用例
runner.run(testunit)
【selenium】HTMLTestRunner测试报告生成的更多相关文章
- 记Selenium HTMLTestRunner 无法生成测试报告的总结
使用Python ,HTMLTestRunner 生成测试报告时,遇到很奇怪的问题,明明运行的结果,没有任何报错,就是不生成测试报告,纠结好久.google+baidu搜索结果也不满意,最后终于解 ...
- 关于Selenium HTMLTestRunner 无法生成测试报告
解决方法 1: filename = ‘E:\testresult.html’,如果是在windows环境,文件名要使用以下几种格式. ①filename = 'E:\\testresult.html ...
- 9.Selenium+HTMLTestRunner无法生成测试报告(Pycharm)
1.若编辑器为Pycharm,代码无任何错误,且运行成功,但是无法生成测试报告,原因如下:(本质是编辑器原因) 若光标在如图位置,右键显示为“run 'unittest in XX'”,若是显示这种, ...
- selenium 自动化测试 测试报告 生成
https://www.cnblogs.com/yoyoketang/p/6140439.html https://www.cnblogs.com/testyao/p/5658200.html 一.下 ...
- 转 生成 HTMLTestRunner 测试报告
转自:http://www.cnblogs.com/hero-blog/p/4128575.html 04.生成 HTMLTestRunner 测试报告 1.HTMLTestRunner 是 P ...
- Python+Selenium----使用HTMLTestRunner.py生成自动化测试报告2(使用PyCharm )
1.说明 在我前一篇文件(Python+Selenium----使用HTMLTestRunner.py生成自动化测试报告1(使用IDLE ))中简单的写明了,如何生产测试报告,但是使用IDLE很麻烦, ...
- Python+Selenium----使用HTMLTestRunner.py生成自动化测试报告1(使用IDLE)
1.说明 自动化测试报告是一个很重要的测试数据,网上看了一下,使用HTMLTestRunner.py生成自动化测试报告使用的比较多,但是呢,小白刚刚入手,不太懂,看了很多博客,终于生成了一个测试报告, ...
- selenium基础(生成测试报告)
测试报告 生成HTML测试报告 下载HTMLTestRunner.py包 下载地址:http://tungwaiyip.info/software/HTMLTestRunner.html 下载后,把H ...
- HtmlTestRunner无法生成HTML报告问题
环境: Python3.6 + Selenium3.3.0 + HtmlTestRunner1.1.0 ON Windows10 IDE: PyCharm HtmlTestRunner地址: http ...
随机推荐
- win10 移动热点自动关闭
解决win10移动热点自动关闭
- PHP:第一章——php中的变量001 /普通赋值/引用赋值/php变量的检查与销毁
<?php //php中的变量: //php中的变量用一个美元符$后面紧跟着变量名来表示,变量名是区分大小写的. //有效的变量只能是字母或者下划线开头,后面跟任意数量的字母.数字.或者下划线. ...
- UVALive 5840 数学题
DES:给出三种材料A,B,C每种的个数.然后组合AB,BC,AC的利润.问能获得的最大利润是多少. 开始一点思路都没有.然后发现可以枚举其中两种的个数.那么最后一种就确定了.还是感觉很机智. #in ...
- HDU 1714 math
#include<stdio.h>#include<string.h>#include<iostream>#include<iomanip>#inclu ...
- TListBox的项目个数
function TCustomListBox.GetCount: Integer; begin if Style in [lbVirtual, lbVirtualOwnerDraw] then Re ...
- ehlib 如何用代码,选中checkbox呢?
TDBGridEh = class(TCustomDBGridEh) public property Col; property Row; property Canvas; // property G ...
- 关于RM中的X3014错误,以及mul() 、天空盒
关于 error X3014: incorrect number of arguments to numeric-type constructor 这个错误应该是某个类似float4 这样的变量初始 ...
- Linux的date常用操作
Linux的date常用操作 ## 在指定的日期上减1天 $ date -d "2012-04-10 -1 day " +%Y-%m-%d 2012-04-09 ## 在指定的日期 ...
- XP停服务,卡巴当后盾——卡巴斯基反病毒软件2014(一年版)
领取地址:http://xp.kaba365.com/3180000.asp 活动说明活动时间:2014年4月9日零时起赠送产品:卡巴斯基反病毒软件2014(一年版)激活码.赠送对象:中国大陆所有XP ...
- HDTunePro汉化版温度显示不正常后需要更改
查找:2564B046000000002564B043替换:2564A848000000002564A1E6 查找:B0432F2564B046替换:A1E62F2564A848