python htmltestrunner报告_为什么python+htmltestrunner生成的测试报告有问题?

该博客内容涉及使用Python的selenium库进行百度首页搜索的自动化测试。测试代码执行成功,但HTMLTestRunner生成的测试报告显示测试条数、成功数、失败数均为0。问题可能在于测试套件的构建或报告输出部分。
摘要由CSDN通过智能技术生成

问题:一个百度首页搜索的一个python+unittest测试,代码执行成功,但是用HTMLTestRunner输出的测试报告里面得内容有问题,具体问题是:测试条数,成功数,失败数都为0

代码

# -*- coding: utf-8 -*-

from selenium import webdriver

import os

import time

import unittest

import re

import HTMLTestRunner

from selenium.webdriver.support.wait import WebDriverWait

from selenium.webdriver.support import expected_conditions

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

from selenium.common.exceptions import NoAlertPresentException

class LoginBaiDu(unittest.TestCase):

def setUp(self):

self.driver = webdriver.Chrome()

self.driver.implicitly_wait(30)

self.base_url = "http://www.baidu.com"

self.verificationErrors = []

self.accept_next_alert = True

print('Done-01')

def test_baidu(self):

self.driver.get(self.base_url)

self.driver.find_element_by_id("su").click()

print('Done-02')

time.sleep(2)

jsClear="$(\"input[id='kw']\").val(\"\")"

self.driver.execute_script(jsClear)

print('Done-03')

time.sleep(2)

jsVal="$(\"input[id='kw']\").val(\"selenium+python\")"

self.driver.execute_script(jsVal)

time.sleep(1)

self.driver.find_element_by_xpath("//input[@id='su']").click()

print('Done-04')

self.driver.close()

print('Done-05')

def tearDown(self):

self.driver.quit()

self.assertEqual([], self.verificationErrors)

print("test down...")

if __name__=="__main__":

test=unittest.TestSuite()

test.addTest(setUp)

test.addTest(test_baidu)

file_path="D:\\workspace\\PythonLearn\\src\\LoginBaiDu\\result.html"

file_result=open(file_path,'wb')

runner=HTMLTestRunner.HTMLTestRunner(stream=file_result,title=u"百度首页测试",description=u"用例执行情况")

runner.run(test)

file_result.close()

生成的报告截图:

bVKux8?w=1359&h=718

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值