General Error when importing firefox profile in Selenium

I have some selenium code which is always throwing up this exception:

Error: [('C:UsersuserAppDataRoamingMozillaFirefoxProfilestp3cz5dm.default-releasestoragedefaultmoz-extension+++81745d9e-096f-4b18-ad35-c2ef2dcf93e4^userContextId=4294967295idb3647222921wleabcEoxlt-eengsairo.sqlite-shm', 'C:UsersuserAppDataLocalTemptmp5h3p7xuzwebdriver-py-profilecopystoragedefaultmoz-extension+++81745d9e-096f-4b18-ad35-c2ef2dcf93e4^userContextId=4294967295idb3647222921wleabcEoxlt-eengsairo.sqlite-shm', '[Errno 13] Permission denied')]

This error just seems to go away when I run the file again or the loop again. I do have an try and except statement to catch it:

 except (InvalidSessionIdException, Error):
        print("Restarting due to Exception InvalidSessionIdException")
        continue    

But this error still pops up and drops out of the while loop. I did not import it like:

from selenium.common.exceptions import NoSuchElementException, StaleElementReferenceException, InvalidSessionIdException

Could you please advise what i need to import, so python recognizes?

Source: Python-3x Questions

LEAVE A COMMENT