Fix loop and support area tag
It appears the output of qtwebkit has a cycle, so we end in an endless loop. This limits the loop to 5 steps.
This commit is contained in:
parent
0432ba68c6
commit
0fe0f84546
@ -288,8 +288,11 @@ 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
|
||||||
while elem is not None:
|
for i in range(5):
|
||||||
if elem.tagName().lower() == 'a':
|
if elem is None:
|
||||||
|
break
|
||||||
|
tag = elem.tagName().lower()
|
||||||
|
if tag == 'a' or tag == 'area':
|
||||||
if elem.attribute('target') == '_blank':
|
if elem.attribute('target') == '_blank':
|
||||||
elem.setAttribute('target', '_top')
|
elem.setAttribute('target', '_top')
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user