试图运行的Python会出现错误

时间:2016-07-07 09:08:09

标签: python selenium python-behave

我正在尝试使用behave来运行selenium测试,但我仍然坚持这个想法。 我已经设置了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完成处理

1 个答案:

答案 0 :(得分:3)

您的追溯返回:&#39; IndentationError:unindent与任何外部缩进级别都不匹配&#39;。

这通常表示您的缩进级别的标签/空格不正确 你能尝试将文件标签重新格式化为4个空格吗?

  

正如凯尔伍德所说,你应该看一下的文件是&features?features \ environment.py&#39;在第11行附近。

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