Q:

Selenium throw no exception in case invalid URL-scheme used

I've written two scripts: one using requests and the other using selenium. 
When I execute my first script, I see that it never prints anything as it can't get past this line res = requests.get(link) when there is an error and as a result the printing never happens. However, in case of selenium, I get different behavior. I know I supplied an invalid link and still I can see the result what this line print("Executing: " + driver.current_url) produces?
How can I stop my selenium script when it hits this line driver.get(link) no matter there is an inavid url supplied or no valid response or no url is there at all?
First script (it behaves in the right way):
import requests

link = "httppss://www.google.com/search?q=selenium"

res = requests.get(link) #error thrown here just as expected
print("Executing: " + res.url)

Second script (it runs smoothly when it sould throw error):
from selenium import webdriver

link = "httppss://www.google.com/search?q=selenium"

driver = webdriver.Chrome()
driver.get(link) #expected any error to be thrown here
print("Executing: " + driver.current_url)
driver.quit()

A:

InvalidSchema is requests-specific exception. requests supports HTTP and HTTPS protocols only, and get_adapter method checks whether URL-schema is in ['HTTP', 'HTTPS'] list. If not InvalidSchema exception raised...
Selenium has no such invalid schema handler, so (as expected) no exception raised in case you want to get URL with schema like "httppss"
You can of course update your selenium.common.exceptions module locally, so it will contain
class InvalidSchemaException(WebDriverException):
    """Raises if URL-schema is not supported"""
    pass

add imports to webdriver module:
from selenium.common.exceptions import (InvalidArgumentException,
                                        WebDriverException, InvalidSchemaException)
from urllib.parse import urlparse

and modify get as
def get(self, url):
    """
    Loads a web page in the current browser session.
    """
    schema = urlparse(url).scheme
    if scheme.upper() not in ['HTTP', 'HTTPS']:
        raise InvalidSchemaException('Schema "%s" is not supported' % scheme)
    self.execute(Command.GET, {'url': url})

but it's just a workaround, you might use this approach only if you really need it

