04、生成 HTMLTestRunner 測試報告
1>下載HTMLTestRunner.py檔案,地址為: Windows平臺: 將下載的檔案放入...\Python27\Lib 目錄下 Linux平臺: 下需要先確定 python 的安裝目錄,開啟終端,輸入 python 命令進入 python 互動模式,通過 sys.path 可以檢視本機 python 檔案目錄,以管理員身份將 HTMLTestRunner.py 檔案考本到/usr/lib/python2.7/dist-packages/ 目錄下
更好用的HTML報告替換附件中的HTMLTestRunner.py。關於HTML報告中顯示出截圖的方法在HTMLTestRunner中已經寫死,所以必須按寫死的路徑來設定檔案件。資料夾順序如下:對HTMLTestRunner中的總結如下:1、設定HTML報告的存放路徑為result2、設定截圖儲存的路徑為result\image\。3、data裡面的圖片用來做圖示4、在程式碼裡面把截圖路徑給打印出來,具體效果如下:
# -*- coding: utf-8 -*-
from selenium
import webdriverimport unittest
import time,sys
importHTMLTestRunner
reload(sys)
sys.setdefaultencoding("utf-8")
classBaidu(unittest.TestCase):
"""百度首頁搜尋測試用例"""
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.implicitly_wait(30)
self.base_url ="http://www.baidu.com"
def test_baidu_search
(self):driver = self.driver
print u"========【case_0001】 百度搜索============="
driver.get(self.base_url +"/")
driver.find_element_by_id("kw").clear()
driver.find_element_by_id("kw").send_keys(u"林志玲")
driver.find_element_by_id("su").click()
now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
#必須要列印路徑HTMLTestRunner才能捕獲並且生成路徑,\image\**.png 是獲取路徑的條件,必須這樣的目錄
pic_path='..\\result\\image\\'+now+'.png'
print pic_path
driver.save_screenshot(pic_path)
time.sleep(2)
def tearDown(self):
self.driver.quit()
if __name__ =="__main__":
now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
testunit = unittest.TestSuite()
testunit.addTest(Baidu("test_baidu_search"))
HtmlFile="..\\result\\"+now+"HTMLtemplate.html"
printHtmlFile
fp = file(HtmlFile,"wb")
runner =HTMLTestRunner.HTMLTestRunner(stream=fp, title=u"百度測試報告", description=u"用例測試情況")
runner.run(testunit)
附件列表
相關推薦
04、生成 HTMLTestRunner 測試報告
1、HTMLTestRunner 是 Python 標準庫的 unittest 模組的一個擴充套件。它生成易於使用的 HTML 測試報告 1>下載HTMLTestRunner.py檔案,地址為: Windows平臺: 將下載的檔案放入...\Python27\Lib 目錄下 Lin
python selenium2示例 - 生成 HTMLTestRunner 測試報告
package chrome imp tde 驗證 sleep == http 技術分享 前言 在python selenium2自動化測試過程中,一個合適的報告是必須的,而HTMLTestRunner模塊為我們提供了一個很好的報告生成功能。 什麽是HTMLTestRunn
Python 同一檔案中,有unittest不執行“if __name__ == '__main__”,不生成HTMLTestRunner測試報告的解決方案
1、問題:Python中同一個.py檔案中同時用unittest框架和HtmlReport框架後,HtmlReport不被執行。 2、為什麼?其實不是HtmlReport不被執行,也不是HtmlReport不生成測試報告,是因為if __name__ == '__main__'中的程式碼根本沒執
Selenium3+生成HTMLTestRunner測試報告+傳送帶附件郵箱
1、匯入各功能模組 from HTMLTestRunner import HTMLTestRunner from email.mime.text import MIMEText #傳送郵件正文 from email.mime.multipart import MIMEMultipart #傳
selenium 生成HtmlTestRunner測試報告
文件名 http 測試套件 需要 報告 進行 單引號 測試 9.png 下載路徑:tungwaiyip.info/software/HTMLTestRunner.html 2改成3 使用: 最後: run 套件的名 在類,或方法裏使用三
手把手教你如何在window下將jenkins+allure整合生成的測試報告通過jenkins配置郵箱自動傳送-04(非常詳細,非常實用)
簡介 上一篇生成測試報告,小夥伴們和童鞋們就又問道,測試報告已經生成了,怎麼傳送給相關的負責人了?小夥伴們和童鞋們不要著急,聽巨集哥慢慢給你道來,心急吃不了熱豆腐哈。這些小夥伴們的表現還是不錯的,還有表現差一點的小夥伴或者童鞋們,竊竊自喜,以為萬事大吉了,NO,還差一步,不把測試報告發出去好好地在領導面
HTMLTestRunner測試報告
生成 main str title scrip .html pen esc unittest if __name__ == "__main__": # unittest.main() S=unittest.TestSuite() S.addTest(I
python - HTMLTestRunner 測試報告模板設置
sting -a back copy mixin rbo not http tde python - HTMLTestRunner 測試報告模板設置 優化模板下載地址: http://download.csdn.net/download/chinayyj2010/100
Selenium(Python)生成Html測試報告
stc max 文件夾 www. info pyc 添加 testsuite 百度 由於Python3已經不支持HTMLTestRunner了, 無論是PyCharm還是pip都無法安裝成功, 所以只能去https://pypi.python.org/pypi/HTMLTe
pycharm----修改腳本默認運行方式及不生成HTML測試報告解決方法
pycharm修改默認運行方法 pycharnm不生成測試報告 pycharm運行腳本的方式 Python做測試寫代碼經常用的工具是pycharm,但是我們在運行代碼的時候會發現有幾種 不同的運行方式,比如:run unittest in xxx.py、run xxx.py,run py.tes
python接口自動化測試二十五:執行所有用例,並生成HTML測試報告
odin 所有 郵件發送 QQ 二進制 multipart 分享圖片 html sse import requestsimport unittestclass TestQQ(unittest.TestCase): ‘‘‘測試QQ號接口‘‘‘
Jmeter 壓力測試生成HTML測試報告(腳本方式執行)
bfc ima 文檔 ESS size 備註 rep suse mage 一、輸入以下命令:1、開到doc 命令輸入:cd C:\Users\issuser\Desktop\lamw備註:文件夾中必須有test.jmx 文件 2、繼續在doc 輸入:D:\soft\apac
基於py2 HTMLTestRunner測試報告修改樣式的原始碼
# coding=utf-8 """ A連線資訊 TestRunner for use with the Python unit testing framework. It generates a HTML report to show the result at a glance. The si
ruby rspec+jenkins+ci_report持續集成生成junit測試報告
report require 默認 jenkins reports rtb ruby pattern rspec 1.加載ci_report gem install ci_reporter_rspec 2.給測試工程編寫rakefile require ‘ci/r
Python生成HTML測試報告
HTMLTestRunner是Python標準庫提供unittest單元測試框架的一個擴充套件,他生成易於使用的HTML測試報告。這個擴充套件只是一HTMLTest Runner.py 檔案 1.下載地址:http://tungwaiyip.info/software/HTMLTestRunn
微信小程式自動化測試-----生成html測試報告
1: 先下載HTMLTestRunner.py檔案:地址http://tungwaiyip.info/software/HTMLTestRunner.html 2:將該檔案儲存在python安裝路徑下的lib資料夾中。在檔案中能import HTMLTestRunner成功,即配置成功。
生成Html 測試報告
1.引入HTMLTestRunner 下載HTMLTestRunner.py 從http://tungwaiyip.info/software/HTMLTestRunner.html 將下載的HTMLTestRunner.py 存放在python的bin路徑下 HTMLTestRunner.p
JMeter 生成HTML測試報告
JMeter 生成HTML測試報告 為什麼? 執行完測試任務,想更直觀的檢視報告,需要生成一個HTML報告; 怎麼做? 首先,在JMeter/bin下執行jmeter命令,執行一遍我們的測試指令碼,並生成以.jtl文字尾的檔案: jmeter -n -t my.jmx
Appium+Python之生成html測試報告
思考:測試用例執行後,如何生成一個直觀漂亮的測試報告呢? 分析:1.unittest單元測試框架本身帶有一個textTestRunner類,可以生成txt文字格式的測試報告,但是頁面不夠直觀 2.我們可以匯入第三方庫,比如常
ANT呼叫JMeter執行指令碼並生成html測試報告
1、 下載解壓ANT 2、 下載解壓JMeter 3、 設定環境變數:ANT_HOME=ANT解壓的主目錄,JMETER_HOME= JMETER解壓的主目錄,將%ANT_HOME%\bin;加入PATH中 4、 將JMeter目錄下的apache