attributeError:' htmltestresult'对象没有属性' _count_relevant_tb_levels'。您的意思是:' _is_relevant_tb_level&#x27 ;?
导入UNITSEST 导入htmltestrunner 来自Selenium Import Webdriver class test_orangehrm(unittest.testcase): @ClassMethod Def SetupClass(CLS): options = webdriver.chromeoptions() options.add_experimenty_option('excludesWitches',['enable-logging']) cls.driver = webdriver.chrome(options = options) cls.driver.maximize_window() def test_homepage(self): self.driver.get(“ https://opensource-demo.orangehrmlive.com/”) 如果名称
def test_Login(self):
self.driver.get("https://opensource-demo.orangehrmlive.com/")
self.driver.find_element_by_xpath("//*[@id='txtUsername']").send_keys("Admin")
self.driver.find_element_by_xpath("//*[@id='txtPassword']").send_keys("admin123")
self.driver.find_element_by_xpath("//*[@id='btnLogin']").click()
self.assertEqual("OrangeHRM123", self.driver.title, "Webpage Title Is Not Matching")
@classmethod
def tearDownClass(cls):
cls.driver.quit()
print("Test Completed")
==“ main ”: UNITTEST.MAIN(testRunner = htmltestrunner.htmltestrunner(output =“ c:/users/hp/pycharmprojects/seleniumpython/Reports)))))
import unittest
import HtmlTestRunner
from selenium import webdriver
class Test_OrangeHRM(unittest.TestCase):
@classmethod
def setUpClass(cls):
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
cls.driver = webdriver.Chrome(options=options)
cls.driver.maximize_window()
def test_HomePage(self):
self.driver.get("https://opensource-demo.orangehrmlive.com/")
self.assertEqual("OrangeHR", self.driver.title, "Webpage Title Is Not Matching")
def test_Login(self):
self.driver.get("https://opensource-demo.orangehrmlive.com/")
self.driver.find_element_by_xpath("//*[@id='txtUsername']").send_keys("Admin")
self.driver.find_element_by_xpath("//*[@id='txtPassword']").send_keys("admin123")
self.driver.find_element_by_xpath("//*[@id='btnLogin']").click()
self.assertEqual("OrangeHRM123", self.driver.title, "Webpage Title Is Not Matching")
@classmethod
def tearDownClass(cls):
cls.driver.quit()
print("Test Completed")
if name=="main":
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="C:/Users/HP/PycharmProjects/seleniumPython/Reports"))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用。
显然,“ _Count_Relevant_tb_levels”在最新版本中不可用,因此您需要转到HTMLTestrunner软件包的源代码。
在您已安装的软件包的HTMLTestrunner文件夹中,寻找result.py
替换这些行:
用
This works for me.
Apparently the "_count_relevant_tb_levels" is not available in the newest versions, so you need to go to the source code of the HtmlTestRunner package.
Inside the HtmlTestRunner folder of the package you have installed, look for result.py
Find the "_exc_info_to_string" method of the "HtmlTestResult" class.
Replace these lines:
with