簡體   English   中英

嘗試運行的Python行為得到錯誤

[英]Python trying to run behave get errors

我試圖使用行為來運行硒測試,但我一直陷於這一想法的開始。 我已經設置了python,selenium並按照應有的方式運行。 我用硒運行python腳本沒有問題。 當我嘗試以行為方式運行它們時,我的問題開始了。 我的python是3.5.2,硒是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完成

您的回溯將返回:'IndentationError:unindent與任何外部縮進級別都不匹配'。

這通常表明您的縮進級別的制表符/空格不正確。
您可以嘗試將制表符重新格式化為4個空格嗎?

正如khelwood指出的那樣,您應該查看的文件是第11行附近的“ features \\ environment.py”。

這通常應該解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM