KeyError: 'browser' with Splinter and Behaving automated testing

KeyError: 'browser' with Splinter and Behaving automated testing

我按照此处的说明进行操作:http://shon.github.io/2014/06/19/ui_testing_and_bdd.html 关于使用 Behaving 设置 Splinter 以 运行 自动化测试。我能够 运行 测试成功,但在测试结束时,它会抛出一条错误消息:

按键错误:'browser'

并且它不会继续测试任何其他功能文件。我是 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'

我发现了问题。它与Feature文件结构有关。功能文件丢失:

 Background:
    Given a browser

这还需要根据此处的信息更改 environment.py 文件:https://github.com/ggozad/behaving