0

我正在尝试使用行为来运行硒测试,但我一直坚持这个想法。我已经设置了 python、selenium 并按照它应该的方式运行。我正在使用 selenium 运行 python 脚本没有问题。当我尝试使用行为运行它们时,我的问题就开始了。我的 python 是 3.5.2,selenium 是 2.53.2,表现是 1.2.5。当我尝试运行任何功能文件时,出现以下错误。如果我尝试使用 PyCharm IDE 或直接从命令提示符运行它并不重要。有没有人知道什么是错的或我做错了什么?

错误:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\behave_runner.py", line 269, in <module>
_BehaveRunner(my_config, base_dir).run()
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\_bdd_utils.py", line 92, in run
number_of_tests = self._get_number_of_tests()
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\_bdd_utils.py", line 206, in _get_number_of_tests
for feature in self._get_features_to_run():
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\behave_runner.py", line 209, in _get_features_to_run
self.__real_runner.run()
  File "C:\Python35\lib\site-packages\behave-1.2.5-py3.5.egg\behave\runner.py", line 672, in run
  File "C:\Python35\lib\site-packages\behave-1.2.5-py3.5.egg\behave\runner.py", line 677, in run_with_paths
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\behave_runner.py", line 92, in load_hooks
super(_RunnerWrapper, self).load_hooks(filename)
  File "C:\Python35\lib\site-packages\behave-1.2.5-py3.5.egg\behave\runner.py", line 631, in load_hooks
  File "C:\Python35\lib\site-packages\behave-1.2.5-py3.5.egg\behave\runner.py", line 303, in exec_file
  File "features\environment.py", line 11
print("Before scenario\n")
                         ^
IndentationError: unindent does not match any outer indentation level

进程以退出代码 1 结束

4

1 回答 1

3

您的回溯返回:'IndentationError: unindent 不匹配任何外部缩进级别'。

这通常表明您的缩进级别的制表符/空格不正确。
您可以尝试将文件制表符重新格式化为 4 个空格吗?

正如 khelwood 所指出的,您应该查看的文件是第 11 行附近的“features\environment.py”。

这通常应该可以解决这个问题。

于 2016-07-07T09:13:49.310 回答