Make sure base URL for resolve_url is absolute
This commit is contained in:
parent
7a65559cce
commit
68595e1736
@ -509,6 +509,9 @@ class WebElementWrapper(collections.abc.MutableMapping):
|
||||
Return:
|
||||
A QUrl with the absolute URL, or None.
|
||||
"""
|
||||
if baseurl.isRelative():
|
||||
raise ValueError("Need an absolute base URL!")
|
||||
|
||||
for attr in ['href', 'src']:
|
||||
if attr in self:
|
||||
text = self[attr].strip()
|
||||
|
@ -958,3 +958,9 @@ def test_resolve_url(attributes, expected):
|
||||
elem = get_webelem(attributes=attributes)
|
||||
baseurl = QUrl('http://www.example.com/')
|
||||
assert elem.resolve_url(baseurl) == expected
|
||||
|
||||
|
||||
def test_resolve_url_relative_base():
|
||||
elem = get_webelem(attributes={'href': 'foo'})
|
||||
with pytest.raises(ValueError):
|
||||
elem.resolve_url(QUrl('base'))
|
||||
|
Loading…
Reference in New Issue
Block a user