首页 > 其他分享 >selenium---生成BeautifulReport报告

selenium---生成BeautifulReport报告

时间:2022-10-20 22:15:36浏览次数:93  
标签:selenium self driver --- BeautifulReport unittest def

现在遇到的难点不在于看不懂,而是看懂了流程思路把握不了,只能不断的重复刷经验以期待能够完全掌握 

 https://www.cnblogs.com/qican/p/15273376.html  转原作者

selenium---生成BeautifulReport报告

备注:

自动化测试过程中, 通过执行测试用例回生成对应的测试报告,在python的单元框架中也有几种测试报告,其中有pytest的html和allure报告,unittest中有HTMLTESTrunner以及BeautifulReport 报告,

BeautifulReport

BeautifulReport也是基于unittest中的一个报告框架,也是以HTML的报告形式进行展示出来的,可以通过pip直接进行安装下载。
安装: pip install BeautifulReport 
验证安装: pip show BeautifulReport 

 

 

 进入到代码里面,看看到底如何使用的,代码这里简单的介绍了我们如何进行使用

 

 

 实战

安装成功了,也通过查看代码处发现如何进行使用了,我们这里通过selenium+unittest+BeautifulReport的方式来演示。

import unittest
import BeautifulReport
from selenium import webdriver
class Test(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://www.baidu.com/')


    def test_01(self):
        '''测试用例01'''
        self.driver.find_element_by_id('kw').send_keys('1111')


    def test_02(self):
        '''测试用例02'''
        self.driver.find_element_by_id('kw').send_keys('222')

    def test_03(self):
        '''测试用例03'''
        self.driver.find_element_by_id('kw').send_keys('333')

    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':

    testunit = unittest.TestSuite()
    # 加载用例
    testunit.addTests(unittest.TestLoader().loadTestsFromTestCase(Test))
    result = BeautifulReport.BeautifulReport(testunit)
    result.report(filename='report', description='测试报告', log_path=None)

  

通过执行后,可以发现在我们的当前目录下生产了一个测试report.html。通过打开html文件进行查看我们的测试报告

 

 

 

标签:selenium,self,driver,---,BeautifulReport,unittest,def
From: https://www.cnblogs.com/chenianmingtong/p/16811483.html

相关文章