Thursday, 2 March 2017


Selenium: Firefox Profile exception Can't load the profile

I use python to open firefox and redirect to google page but it show empty page and get error. 
This is the Panel constructor:


Traceback (most recent call last):
  File "C:/Users/KennethHu/PycharmProjects/Web_Automation/Hello Selenium.py", line 3, in 
    driver=webdriver.Firefox()
  File "C:\Programs\Python36\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__
    self.binary, timeout)
  File "C:\Programs\Python36\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "C:\Programs\Python36\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "C:\Programs\Python36\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 108, in _wait_until_connectable
    % (self.profile.path))
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: C:\Users\KENNET~1\AppData\Local\Temp\tmp2rghen87 If you specified a log_file in the FirefoxBinary constructor, check it for details.


Solution: 

elenium team fixed in latest version. For almost all environments the fix is:
pip install -U selenium
Unclear at which version it was fixed (apparently r13122), but certainly by 2.26.0 (current at time of update) it is fixed.

You may get Failure like this Failure to observe this step will give you an error 
selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH.

Download following driver into your project folder. 

Chrome:https://sites.google.com/a/chromium.org/chromedriver/downloads
Edge:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Firefox:https://github.com/mozilla/geckodriver/releases
Safari:https://webkit.org/blog/6900/webdriver-support-in-safari-10/

No comments:

Post a Comment

how-to-recursively-create-subfolder-in-each-folder-of-a-directory-in-cmd

test.cmd: @echo off setlocal for /f "usebackq tokens=*" %%a in (`dir /b /a:d`) do ( rem enter the directory pushd %%a echo...