We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1、需要修改【python2版本】的这几个地方 第94行,将import StringIO修改成import io
第539行,将self.outputBuffer = StringIO.StringIO()修改成self.outputBuffer = io.StringIO()
第642行,将if not rmap.has_key(cls):修改成if not cls in rmap:
第766行,将uo = o.decode('latin-1')修改成uo = e
第775行,将ue = e.decode('latin-1')修改成ue = e
第631行,将print >> sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)修改成print(sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime))
2、我将文件上传到这里备份 HTMLTestRunner.py【py3版本,使用删除后面的】.txt
3、测试代码 将上面的HTMLTestRunner.py 跟下面test.py放在同一目录下 1)安装selenium 2)将geckodriver.exe 文件下载,放到python安装目录:C:\Python36下
geckodriver.exe【删除后面的】.txt
3)用命令行执行python test.py, 不然在pycharm里面总是报ok的那种
# -*- coding: utf-8 -*- from selenium import webdriver from HTMLTestRunner import HTMLTestRunner # 导入HTMLTestRunner模块 import unittest, time class BaiduIdeTest(unittest.TestCase): # 三引号表示doc string类型注释,用来描述函数、类和方法 '''baidu search testing''' def setUp(self): self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "https://www.baidu.com/" def test_baidu_ide(self): '''Search Keyword''' driver = self.driver driver.get(self.base_url) driver.find_element_by_id("kw").clear() driver.find_element_by_id("kw").send_keys("HTMLTestRunner") driver.find_element_by_id("su").click() time.sleep(5) self.assertEqual(u"HTMLTestRunner_百度搜索", driver.title) def tearDown(self): self.driver.quit() if __name__ == "__main__": # 构造测试套件 testsuit = unittest.TestSuite() testsuit.addTest(BaiduIdeTest("test_baidu_ide")) # 按照一定格式获取当前时间,%Y表示带世纪的年(2019),%y表示不带世纪的年(19),time.strftime()表示获得当前时间并格式化字符串 now = time.strftime("%Y%m%d_%H%M%S") # 将当前时间加入到报告文件名称中 filename = './' + now + 'result.html' # 定义测试报告存放路径,通过open()方法以二进制写模式('wb')打开当前目录下的result.heml,如果没有,则自动创建。 fp = open('./result.html', 'wb') # 定义测试报告,调用HTMLTestRunner模块下的HTMLTestRunner类,stream 指定测试报告文件,title 定义测试报告的标题,description 定义测试报告的副标题 runner = HTMLTestRunner(stream=fp, title='自动化测试报告', description='用例执行情况:') # 通过HTMLTestRunner的run()方法来运行测试套件中的测试用例 runner.run(testsuit) # 关闭测试报告 fp.close() print('11111111')
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1、需要修改【python2版本】的这几个地方
第94行,将import StringIO修改成import io
第539行,将self.outputBuffer = StringIO.StringIO()修改成self.outputBuffer = io.StringIO()
第642行,将if not rmap.has_key(cls):修改成if not cls in rmap:
第766行,将uo = o.decode('latin-1')修改成uo = e
第775行,将ue = e.decode('latin-1')修改成ue = e
第631行,将print >> sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)修改成print(sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime))
2、我将文件上传到这里备份
HTMLTestRunner.py【py3版本,使用删除后面的】.txt
3、测试代码
将上面的HTMLTestRunner.py 跟下面test.py放在同一目录下
1)安装selenium
2)将geckodriver.exe 文件下载,放到python安装目录:C:\Python36下
geckodriver.exe【删除后面的】.txt
3)用命令行执行python test.py, 不然在pycharm里面总是报ok的那种
The text was updated successfully, but these errors were encountered: