Complete coverage for webelem

This commit is contained in:
Kevin Velghe 2016-03-31 10:25:44 +02:00
parent ef6ffd6a3a
commit e90ad3d9c0
2 changed files with 11 additions and 6 deletions

View File

@ -288,7 +288,7 @@ class WebElementWrapper(collections.abc.MutableMapping):
def remove_blank_target(self): def remove_blank_target(self):
"""Remove target from link.""" """Remove target from link."""
elem = self._elem elem = self._elem
for i in range(5): for _ in range(5):
if elem is None: if elem is None:
break break
tag = elem.tagName().lower() tag = elem.tagName().lower()

View File

@ -347,11 +347,16 @@ class TestWebElementWrapper:
elem_child.remove_blank_target() elem_child.remove_blank_target()
assert elem._elem.attribute('target') == '_top' assert elem._elem.attribute('target') == '_top'
elem = get_webelem(tagname='button') elem[0] = get_webelem(tagname='div')
elem_child = get_webelem(tagname='div', parent=elem._elem) for i in range(1, 5):
elem_child._elem.encloseWith(elem._elem) elem[i] = get_webelem(tagname='div', parent=elem[i-1])
elem_child.remove_blank_target() elem[i]._elem.encloseWith(elem[i-1]._elem)
assert 'target' not in elem_child elem[4].remove_blank_target()
for i in range(5):
assert 'target' not in elem[i]
elem = get_webelem(tagname='div')
elem.remove_blank_target()
assert 'target' not in elem assert 'target' not in elem