2017-09-06 116 views
0

運行,我只是能當我運行它以管理員身份運行我的Python代碼硒「無法創建用戶數據目錄臨時目錄」的錯誤。如果我運行它通常我得到以下錯誤:當不作爲管理員

C:\startup>Python C:/startup/startupWebDriverScript.py  
Traceback (most recent call last): 
    File "C:/startup/startupWebDriverScript.py", line 26, in connectGuest 
    driver = webdriver.Chrome(chrome_options=chromeOptions,executable_path="C:/Python36/Chrome Webdriver/chromedriver.exe") 
    File "C:\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__ 
    desired_capabilities=desired_capabilities) 
    File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 140, in __init__ 
    self.start_session(desired_capabilities, browser_profile) 
    File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 229, in start_session 
    response = self.execute(Command.NEW_SESSION, parameters) 
    File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute 
    self.error_handler.check_response(response) 
    File "C:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response 
    raise exception_class(message, screen, stacktrace) 
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot create temp dir for user data dir 
    (Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a),platform=Windows NT 10.0.15063 x86_64) 

這是我的代碼:

chromeOptions = Options() 
    chromeOptions.add_argument("--use-fake-ui-for-media-stream") 
    chromeOptions.add_argument("--kiosk") 
    chromeOptions.add_argument("--disable-notifications") 
    chromeOptions.add_argument("--disable-infobars") 
    driver = webdriver.Chrome(chrome_options=chromeOptions,executable_path="C:/Python36/Chrome Webdriver/chromedriver.exe") 

我使用python 3.6中,Windows 10和基於我的經驗硒3.5

回答

1

,您可能遇到以下情況之一。
1)您的磁盤已滿,因此沒有足夠的可用磁盤空間。嘗試清空回收站或檢查過度生成的臨時文件並清除它們。

2),或已安裝使用管理員權限的包,因此你的腳本沒有正確的權限來執行。

3)TMP環境變量可能需要修改。
右鍵單擊計算機,然後單擊屬性 - >高級系統設置 - >環境變量 - 「爲用戶變量」>
並更改TEMP和TMP瓦爾值「C:\ TEMP」。

0

嘗試了很多不同的方法後,我決定降級的Chrome網絡驅動程序,它開始工作了罰款。

+0

差不多好奇,想知道哪個日誌/效應觸發降級的'chromedriver'的想法? – DebanjanB

+0

其實我將我的設置與另一個類似的工作設置進行了比較,唯一的區別是鉻合金驅動程序版本。不幸的是,我不明白底層問題究竟是什麼。 –