简体   繁体   中英

How to setup portable Firefox using selenium/python on windows?

I've tried this python script to open a url in portable Firefox on windows, but I get SessionNotCreatedException traceback.

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('path\\to\\FirefoxPortable32.exe')
exec_path = "path\\to\\geckodriver32.exe"
browser = webdriver.Firefox(executable_path=exec_path, firefox_binary=binary)
browser.get('some_url')

Here's the traceback:

File "tst.py", line 20, in browser = webdriver.Firefox(executable_path=exec_path, firefox_binary=binary) File "C:\\Program Files (x86)\\Python37-32\\lib\\site-packages\\selenium\\webdriver\\firefox\\webdriver.py", line 174, in init keep_alive=True) File "C:\\Program Files (x86)\\Python37-32\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "C:\\Program Files (x86)\\Python37-32\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\\Program Files (x86)\\Python37-32\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\\Program Files (x86)\\Python37-32\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Messa ge: Unable to find a matching set of capabilities

I am using:

windows 7 (64 bit)
python 3.7
selenium 3.141
geckdriver v0.24.0 (64 bit)
FirefoxPortable 68.0.1 (64 bit)

Any idea how to get the portable Firefox working?

Change the path to Firefox binary to the firefox.exe file inside "App" folder. Eg 'path\\\\to\\\\FirefoxPortable\\\\App\\\\Firefox\\\\firefox.exe'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM