我有两个文件:
步骤.py:
from lettuce import *
from splinter.browser import Browser
@before.harvest
def set_browser():
world.browser = Browser('webdriver.chrome')
@step(u'Given I visit "([^"]*)"')
def given_i_visit(step, url):
world.browser.visit(url)
测试功能:
Feature: Do some basic tests
Scenario: Check whether the website is accessable
Given I visit "/"
对他们运行生菜会返回:
Feature: Do some basic tests # features/test.feature:1
Scenario: Check whether the website is accessable # features/test.feature:2
Given I visit "/" # features/steps.py:8
Traceback (most recent call last):
File "/..../site-packages/lettuce/core.py", line 125, in __call__
ret = self.function(self.step, *args, **kw)
File "/..../test/features/steps.py", line 9, in given_i_visit
world.browser.visit(url)
AttributeError: 'thread._local' object has no attribute 'browser'
1 feature (0 passed)
1 scenario (0 passed)
1 step (1 failed, 0 passed)
关于可能出现问题的任何想法?