Skip to content
This repository has been archived by the owner on Mar 15, 2019. It is now read-only.

Commit

Permalink
Bugfix: Use step variable instead of step decorator
Browse files Browse the repository at this point in the history
Previously, this would fail in __exit__ with
AttributeError: 'function' object has no attribute 'sentence'

To do this, the wait_for_content API had to be changed and
now requires step as the first parameter.
  • Loading branch information
rbu committed Aug 16, 2011
1 parent 11b9925 commit 1909d32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ trunk
-----

- Adding a guard to fail properly if the field is not found.
- API change: wait_for_content now expects a step as the first parameter

0.1.3
-----
Expand Down
7 changes: 7 additions & 0 deletions lettuce_webdriver/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import unittest

from lettuce import world
from lettuce.core import Step
from lettuce_webdriver.tests import html_pages

def setUp():
Expand Down Expand Up @@ -39,3 +40,9 @@ def test_find_button(self):
assert find_button(world.browser, 'Submit!')
assert find_button(world.browser, 'submit_tentative')
assert find_button(world.browser, 'Submit as tentative')

def test_wait_for_content(self):
from lettuce_webdriver.webdriver import wait_for_content
step = Step("foobar", [])
self.assertRaises(AssertionError, wait_for_content, step, world.browser, 'text not on the page', timeout=0)

4 changes: 2 additions & 2 deletions lettuce_webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def wait_for_elem(browser, xpath, timeout=15):
return elems


def wait_for_content(browser, content, timeout=15):
def wait_for_content(step, browser, content, timeout=15):
start = time.time()
while time.time() - start < timeout:
if content in world.browser.page_source:
Expand Down Expand Up @@ -106,7 +106,7 @@ def should_not_see_id(step, element_id):

@step('I should see "([^"]+)" within (\d+) seconds?')
def should_see_in_seconds(step, text, timeout):
wait_for_content(world.browser, text, int(timeout))
wait_for_content(step, world.browser, text, int(timeout))


@step('I should see "([^"]+)"')
Expand Down

0 comments on commit 1909d32

Please sign in to comment.