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):
"""Remove target from link."""
elem = self._elem
for i in range(5):
for _ in range(5):
if elem is None:
break
tag = elem.tagName().lower()

View File

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