Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python试图运行behave get错误_Python_Selenium_Python Behave - Fatal编程技术网

Python试图运行behave get错误

Python试图运行behave get错误,python,selenium,python-behave,Python,Selenium,Python Behave,我正试图使用behave来运行selenium测试,但我还停留在这个想法的开始阶段。 我已经设置了python、selenium并按其应有的方式进行操作。我正在使用selenium运行python脚本,没有问题。我的问题开始于我试图用behave运行它们。我的python是3.5.2,selenium是2.53.2,behave是1.2.5。 当我尝试运行任何功能文件时,会出现以下错误。无论我是尝试使用PyCharm IDE运行它,还是直接从命令提示符运行它。有人知道我做错了什么吗 错误: Tr

我正试图使用behave来运行selenium测试,但我还停留在这个想法的开始阶段。 我已经设置了python、selenium并按其应有的方式进行操作。我正在使用selenium运行python脚本,没有问题。我的问题开始于我试图用behave运行它们。我的python是3.5.2,selenium是2.53.2,behave是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
回溯(最近一次呼叫最后一次):
文件“C:\Program Files(x86)\JetBrains\PyCharm 4.0.5\helpers\PyCharm\behave\u runner.py”,第269行,在中
_BehaveRunner(我的配置,基本目录).run()
文件“C:\Program Files(x86)\JetBrains\PyCharm 4.0.5\helpers\PyCharm\\u bdd\u utils.py”,第92行,正在运行
测试次数=自我。获取测试次数()
文件“C:\Program Files(x86)\JetBrains\PyCharm 4.0.5\helpers\PyCharm\\u bdd\u utils.py”,第206行,在“获取”测试的“编号”中
用于self中的功能。\u获取\u功能\u以\u运行():
文件“C:\Program Files(x86)\JetBrains\PyCharm 4.0.5\helpers\PyCharm\behave\u runner.py”,第209行,在“获取”功能“运行”中
self.\u real\u runner.run()
文件“C:\Python35\lib\site packages\behave-1.2.5-py3.5.egg\behave\runner.py”,第672行,运行中
文件“C:\Python35\lib\site packages\behave-1.2.5-py3.5.egg\behave\runner.py”,第677行,运行路径为
文件“C:\Program Files(x86)\JetBrains\PyCharm 4.0.5\helpers\PyCharm\behave\u runner.py”,第92行,在加载钩子中
超级(_RunnerWrapper,self)。加载_挂钩(文件名)
文件“C:\Python35\lib\site packages\behave-1.2.5-py3.5.egg\behave\runner.py”,第631行,在load\u钩子中
文件“C:\Python35\lib\site packages\behave-1.2.5-py3.5.egg\behave\runner.py”,第303行,在exec\u文件中
文件“features\environment.py”,第11行
打印(“在方案之前\n”)
^
缩进错误:未缩进与任何外部缩进级别不匹配

进程结束,退出代码为1

您的回溯返回:“缩进错误:未缩进不匹配任何外部缩进级别”

这通常表明缩进级别的制表符/空格不正确。
你能把文件的制表符改成4个空格吗

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


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

您的回溯返回:“缩进错误:未缩进不匹配任何外部缩进级别”

这通常表明缩进级别的制表符/空格不正确。
你能把文件的制表符改成4个空格吗

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


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

您的缩进是否在“features\environment.py”中出错?您的缩进是否在“features\environment.py”中出错?