我遵循了此处的说明:http://shon.github.io/2014/06/19/ui_testing_and_bdd.html关于使用Behaving设置Splinter以运行自动测试。我可以成功运行测试,但在测试结束时,它会抛出一个错误:
KeyError:"浏览器"
而且它不会继续测试任何附加的功能文件。我对python还很陌生,需要一些帮助来解决这个问题。
Exception KeyError: 'browser'
Traceback (most recent call last):
File "/usr/local/bin/behave", line 11, in <module> sys.exit(main())
File "/Library/Python/2.7/site-packages/behave/__main__.py", line 109, in main
failed = runner.run()
File "/Library/Python/2.7/site-packages/behave/runner.py", line 672, in run
return self.run_with_paths()
File "/Library/Python/2.7/site-packages/behave/runner.py", line 693, in run_with_paths
return self.run_model()
File "/Library/Python/2.7/site-packages/behave/runner.py", line 483, in run_model
failed = feature.run(self)
File "/Library/Python/2.7/site-packages/behave/model.py", line 523, in run
failed = scenario.run(runner)
File "/Library/Python/2.7/site-packages/behave/model.py", line 867, in run
runner.run_hook('before_scenario', runner.context, self)
File "/Library/Python/2.7/site-packages/behave/runner.py", line 405, in run_hook
self.hooks[name](context, *args)
File "features/environment.py", line 48, in before_scenario
context.browser = default_browser
File "/Library/Python/2.7/site-packages/behave/runner.py", line 223, in __setattr__
record = self._record[attr]
KeyError: 'browser'
我发现了这个问题。它与功能文件结构有关。功能文件丢失:
Background:
Given a browser
这还需要根据此处的信息更改environment.py文件:https://github.com/ggozad/behaving