Skip to content

Commit e58ea27

Browse files
committed
remove duplicate (and confusing) wait_for method
we had both a `wait_for` and a `wait_for_element` method, one had it’s own retry, while the other passed that responsibility to the ByClause. I’ve decided the ByClause is responsible for the behavior here, and `wait_for_element` seemed too verbose given the element definition are the required arguments. This also officially makes `wait_for` just a wrapper around passing the browser to a ByClause.
1 parent 0ac31d4 commit e58ea27

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

ngSe/browser.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def quit(self):
6767
raise
6868

6969
def wait_for(self, value, by=By.ID):
70-
"""Waits for an element to appear on screen
70+
"""Waits for an element according to the passed ByClause
71+
72+
This is really just a wrapper around passing the browser to a ByClause, allowing for much cleaner syntax.
7173
"""
7274
# Contract
7375
must_be(value, "value", basestring)
@@ -239,8 +241,3 @@ def text_is_present(self, text, *args, **kwargs):
239241
@retry
240242
def _text_is_present(self, text):
241243
self.find_element_by_tag_name('body').text.index(text)
242-
243-
@retry
244-
def wait_for_element(self, value, by=By.CSS_SELECTOR):
245-
must_be(by, "by", ByClause)
246-
return by.wait(value, self)

ngSe/by.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class ByClause(object):
5151
appropriately.
5252
"""
5353

54+
# TODO[TJ] make methods (convert, wait, find) officially defined as internal-only (prepend with a dunder). This will allow refactoring of how this is used within a browser without breaking 'proper' implimentaions. This may also require some warning to people implimenting custom ByClauses. There's a discussion here.
55+
5456
def __init__(self, by, f):
5557
# Contract
5658
must_be(by, "by", basestring)

0 commit comments

Comments
 (0)