Selenium错误 `AssertionError: 列表不同` 在tearDown中

0 投票
1 回答
964 浏览
提问于 2025-04-16 15:47

我刚开始学习Python,第一件事就是为我用PHP和Python开发的应用程序编写自动化测试脚本。为此,我开始使用Selenium IDE,然后把代码导入到Python中,粘贴到我的编辑器里。

但是当我试图从编辑器运行这个脚本时,出现了一个错误:

E
======================================================================
ERROR: test (__main__.dash)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\workspace\test\dash.py", line 70, in tearDown
    self.assertEqual([], self.verificationErrors)
AssertionError: Lists differ: [] != ['False is not True', 'False i...

Second list contains 2 additional elements.
First extra element 0:
False is not True

- []
+ ['False is not True', 'False is not True']

----------------------------------------------------------------------
Ran 1 test in 31.641s

FAILED (errors=1)

我完全不知道这个错误是从哪里来的。

1 个回答

1

在你的 dash.py 文件中,有这样一行代码:

self.assertEqual([], self.verificationErrors) 

这行代码的意思是,你在检查我们的 verificationErrors 这个列表是否是空的。

但是在你的运行过程中,这个列表并不是空的,它里面有两个内容:

  • False 不是 True
  • True 不是 False

简单来说,这意味着你的测试,无论是什么,都是没有通过的。现在没有更多的信息,很难进一步帮助你。

撰写回答