Skip to content

Commit

Permalink
Wait for elements to become visible properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Kotlyarov committed Oct 3, 2014
1 parent 0c8305f commit 7ffd849
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lettuce_webdriver/webdriver.py
Expand Up @@ -113,13 +113,19 @@ def element_not_contains(step, element_id, value):
assert_false(step, elem)


@wait_for
def wait_for_visible_elem(browser, xpath):
elem = browser.find_elements_by_xpath(str(xpath))
if not elem:
return False
return elem[0].is_displayed()


@step(r'I should see an element with id of "(.*?)" within (\d+) seconds?$')
def should_see_id_in_seconds(step, element_id, timeout):
elem = wait_for_elem(world.browser, 'id("%s")' % element_id,
timeout=int(timeout))
elem = wait_for_visible_elem(world.browser, 'id("%s")' % element_id,
timeout=int(timeout))
assert_true(step, elem)
elem = elem[0]
assert_true(step, elem.is_displayed())


@step('I should see an element with id of "(.*?)"$')
Expand Down

0 comments on commit 7ffd849

Please sign in to comment.