Skip to content

Commit

Permalink
fix nameMatches
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Aug 29, 2017
1 parent a5ff674 commit 8b36835
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
7 changes: 0 additions & 7 deletions tests/test_client.py
Expand Up @@ -100,13 +100,6 @@ def test_alert():
# #print s.alert.text
# pass

def test_text_contains():
with c.session('com.apple.Preferences') as s:
s(text='Bluetooth').get()
assert s(textContains="Blue").exists
assert not s(text="Blue").exists
assert s(text="Bluetooth").exists

@mark.skip("hard to test")
def test_alert_wait():
pass
Expand Down
14 changes: 13 additions & 1 deletion tests/test_session.py
Expand Up @@ -105,4 +105,16 @@ def test_session_wait_gone():
elem.wait_gone(1.0)
assert not elem.wait_gone(1.0, raise_error=False)
s.swipe_left()
assert elem.wait_gone(1.0)
assert elem.wait_gone(1.0)

def test_text_contains_matches():
with c.session('com.apple.Preferences') as s:
s(text='Bluetooth').get()
assert s(textContains="Blue").exists
assert not s(text="Blue").exists
assert s(text="Bluetooth").exists
assert s(textMatches="Blue?").exists
assert s(nameMatches="Blue?").exists
assert not s(textMatches="^lue?").exists
assert not s(textMatches="^Blue$").exists
assert s(textMatches=r"^(Blue|Red).*").exists
6 changes: 3 additions & 3 deletions wda/__init__.py
Expand Up @@ -615,9 +615,9 @@ def __init__(self, httpclient, session,
if self.class_name and not self.class_name.startswith('XCUIElementType'):
self.class_name = 'XCUIElementType'+self.class_name
if self.name_regex:
if not self.name_regex.startswith('^'):
if not self.name_regex.startswith('^') and not self.name_regex.startswith('.*'):
self.name_regex = '.*' + self.name_regex
if not self.name_regex.startswith('$'):
if not self.name_regex.endswith('$') and not self.name_regex.endswith('.*'):
self.name_regex = self.name_regex + '.*'
self.parent_class_chains = parent_class_chains

Expand Down Expand Up @@ -958,4 +958,4 @@ def clear_text(self):
# return Selector(self.__base_url, self._id, **kwargs)

# todo lot of other operations
# tap_hold
# tap_hold

0 comments on commit 8b36835

Please sign in to comment.