1
我正在用selenium webdriver創建一個python腳本。我需要使用在Firefox的擴展,但是當我用小腳本測試,該腳本會產生這樣的錯誤:權限在WebDriver中加載Firefox擴展時被拒絕
Traceback (most recent call last):
File "C:\Users\User\Desktop\Bot\Mania.py", line 8, in <module>
firefoxProfile.add_extension(elem)
File "C:\Python34\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 93, in add_extension
self._install_extension(extension)
File "C:\Python34\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 264, in _install_extension
with open(os.path.join(tmpdir, name), 'wb') as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\User\\AppData\\Local\\Temp\\tmpzq3rmztk.firebug-2.0.11-fx.xpi\\content/firebug/'
[Finished in 0.4s with exit code 1]
示例代碼是:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
import os
firefoxProfile = FirefoxProfile()
elem = "quickjava-2.0.6-fx.xpi"
firefoxProfile.add_extension(elem)
firefoxProfile.set_preference("thatoneguydotnet.QuickJava.startupStatus.CSS", 2)
driver = webdriver.Firefox(firefoxProfile)
driver.get('http://www.google.cl')
PS:該插件-on與腳本位於同一文件夾中。我測試了完整路徑,但它不起作用。