Skip to content

Commit

Permalink
fixes for recent chnages
Browse files Browse the repository at this point in the history
  • Loading branch information
lmtierney committed Mar 10, 2019
1 parent c55193a commit 8362175
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion nerodia/elements/i_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def wd(self):
"""
return FramedDriver(super(IFrame, self).wd, self.browser)

@property
def to_subtype(self):
"""
Cast this Element instance to a more specific subtype.
Expand Down
2 changes: 1 addition & 1 deletion nerodia/locators/element/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def check_match(how, expected):

matches = all(check_match(how, expected) for how, expected in values_to_match.items())

if values_to_match.get('text'):
if values_to_match.get('text') and matches:
self._deprecate_text_regexp(element, values_to_match)

return matches
Expand Down
21 changes: 11 additions & 10 deletions tests/browser/elements/div_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,26 @@ def test_finds_all_attribute_methods(browser):

class TestDivDeprecationWarnings(object):
def test_does_not_throw_deprecation_when_still_matched_by_text_content(self, browser, caplog):
browser.div(text=compile(r'some visible')).exists
browser.div(text=compile(r'some visible')).locate()
assert 'DEPRECATION' not in caplog.text

def test_does_not_throw_deprecation_with_complex_regexp_matched_by_text_content(self, browser, caplog):
browser.div(text=compile(r'some (in|)visible')).locate()
assert 'DEPRECATION' not in caplog.text

def test_throws_deprecation_when_no_longer_matched_by_text_content(self, browser, caplog):
browser.div(text=compile(r'some visible$')).exists
browser.div(text=compile(r'some visible$')).locate()
assert "Using 'text' locator with RegExp {!r} to match an element that includes hidden " \
"text is deprecated. Use 'visible_text' " \
"instead.".format(compile(r'some visible$')) in caplog.text

def test_trows_deprecation_when_begins_to_be_matched_by_text_content(self, browser, caplog):
browser.div(text=compile(r'some hidden')).exists
assert "Using 'text' locator with RegExp {!r} to match an element that includes hidden " \
"text is deprecated. Use 'visible_text' " \
"instead.".format(compile(r'some hidden')) in caplog.text

def test_does_not_throw_deprecation_when_still_not_matched_by_text_content(self, browser, caplog):
browser.div(text=compile(r'does_not_exist')).exists
def test_does_not_throw_deprecation_when_element_does_not_exist(self, browser, caplog):
browser.div(text=compile(r'definitely not there')).locate()
assert 'DEPRECATION' not in caplog.text

def test_does_not_locate_entire_content_with_regular_expressions(self, browser, caplog):
assert not browser.div(text=compile(r'some visible some hidden')).exists


class TestDivManipulation(object):
# click
Expand Down

0 comments on commit 8362175

Please sign in to comment.