【问题标题】:AttributeError: 'HtmlTestResult' object has no attribute '_count_relevant_tb_levels'. Did you mean: '_is_relevant_tb_level'?AttributeError:“HtmlTestResult”对象没有属性“_count_relevant_tb_levels”。你的意思是:'_is_relevant_tb_level'?
【发布时间】:2022-06-14 02:40:13
【问题描述】:

导入单元测试 导入 HtmlTestRunner 从硒导入网络驱动程序 类 Test_OrangeHRM(unittest.TestCase): @classmethod 默认设置类(cls): 选项 = 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, "网页标题不匹配")

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")

如果 name=="ma​​in": unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="C:/Users/HP/PycharmProjects/seleniumPython/Reports"))

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
  • 这是一个在 selenium python 中使用 html test-Runner 运行的带有 html 报告的测试。但是在运行我的代码时由 phycharm ide 创建的 result.py 中添加定义函数后,它不是显示任何错误,我的程序正在运行。谢谢。

标签: python-3.x selenium-webdriver


【解决方案1】:

我有同样的问题,我所做的是在 result.py 文件中编写 _count_relevant_tb_levels(self, tb) 的函数定义。但这使它仅限于我的系统,我不能让此代码可移植。您能解释一下您的解决方案并进一步帮助我吗?

【讨论】:

    猜你喜欢
    • 2022-07-18
    • 2020-11-24
    • 2019-12-23
    • 1970-01-01
    • 2021-12-10
    • 1970-01-01
    • 1970-01-01
    • 2018-02-18
    • 2019-10-31
    相关资源
    最近更新 更多