Try Except clause for Selenium Webdriver in Python.
Most Common Exception Errors
- IOError – It occurs on errors like a file fails to open.
- ImportError – If a python module can’t be loaded or located.
- ValueError – It occurs if a function gets an argument of right type but an inappropriate value.
- KeyboardInterrupt – It gets hit when the user enters the interrupt key (i.e. Control-C or Del key)
- EOFError – It gets raised if the input functions (input()/raw_input()) hit an end-of-file condition (EOF) but without reading any data.
except IOError:
print('Error occurred while opening the file.')
except ValueError:
print('Non-numeric input detected.')
except ImportError:
print('Unable to locate the module.')
except EOFError:
print('Identified EOF error.')
except KeyboardInterrupt:
print('Wrong keyboard input.')
except:
print('An error occurred.')