Using sst in Lettuce

Asked by Le Chi Thu

When I use use sst actions in the Lettuce steps, the browser object is not initialized. Which is the best way to extent sst to support Lettuce ? http://lettuce.it/index.html

See the example below:

blog.feature:

Feature: Personal Blog

  Scenario: Visit the main page
   Given I am at http://localhost:4000
   Then I should see the title Rodney's Corner

steps.py:

from sst.actions import *
from lettuce import *

@before.each_scenario
def setup_browser(scenario):
 #start(browser_type='Chrome')
 pass

@after.each_scenario
def teardown_browser(scenario):
 close_window()

@step('I am at (.*)')
def i_am_at(step, url):
    go_to(url)

@step('I should see the title (.*)')
def should_see_the_title(step, title):
    assert_title(title)

Error messages:
Then I should see the title Rodney's Corner # \features\steps.py:18
=============================================
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\lettuce\registry.py", line 88, in call_hook
    callback(*args, **kw)
  File "D:\home\projects\lettuce_2\features\steps.py", line 11, in teardown_browser
    close_window()
  File "c:\python27\lib\site-packages\sst\actions.py", line 1108, in close_window
    _test.browser.close()
AttributeError: 'NoneType' object has no attribute 'browser'

Died with 'NoneType' object has no attribute 'browser'
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\lettuce\__init__.py", line 164, in run
    failfast=self.failfast))
  File "c:\python27\lib\site-packages\lettuce\core.py", line 1219, in run
    scenarios_ran.extend(scenario.run(ignore_case, failfast=failfast))
  File "c:\python27\lib\site-packages\lettuce\core.py", line 733, in run
    call_hook('after_each', 'scenario', self)
  File "c:\python27\lib\site-packages\lettuce\registry.py", line 88, in call_hook
    callback(*args, **kw)
  File "D:\home\projects\lettuce_2\features\steps.py", line 11, in teardown_browser
    close_window()
  File "c:\python27\lib\site-packages\sst\actions.py", line 1108, in close_window
    _test.browser.close()
AttributeError: 'NoneType' object has no attribute 'browser'

0 feature (0 passed)
0 scenario (0 passed)
0 step (0 passed)

Question information

Language:
English Edit question
Status:
Answered
For:
selenium-simple-test Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Vincent Ladeuil (vila) said :
#1

This has been fixed on sst trunk but you should be aware that if starting a browser is handled automatically for sst scripts you need to use sst.cases.SSTTestCase as a base class to get access to more advanced features.

I.e. sst.actions.start (commented out in your example) has been removed and sst.actions.close() requires a test object ('_test' is a hint that should not rely on private stuff ;).

Also, when I say 'fixed', the SSTTestCase object will now properly initalized its 'browser' attribute. But you still need to properly use an SSTTestCase object to get a browser properly initialized.

Can you help with this problem?

Provide an answer of your own, or ask Le Chi Thu for more information if necessary.

To post a message you must log in.