-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Open
Labels
Description
Description
When you call driver.get() or driver.browsing_context.navigate()), it attempts to navigate to a URL, even if the URL is malformed.
Browsers don't handle this very well. For example...
if you do:
driver.get("example.com")
or
driver.get("http//example.com")
Chrome will just not navigate and not return any error (Firefox returns an error).
Proposed change:
If we validate the URL before attempting navigation, we can raise a useful exception: raise InvalidArgumentException("Invalid URL").
Here is some example code for validation:
from urllib.parse import urlparse
def is_valid_url(url):
try:
result = urlparse(url)
return bool(result.scheme)
except AttributeError:
return FalseThis validates it can be parsed as a URL and contains a scheme.
Have you considered any alternatives or workarounds?
No response
Does this apply to specific language bindings?
Python
What part(s) of Selenium does this relate to?
No response