Как мне заставить Selenium на Python подключаться к существующему экземпляру Firefox - я не могу подключиться к порту ма ⇐ Python
Как мне заставить Selenium на Python подключаться к существующему экземпляру Firefox - я не могу подключиться к порту ма
I am trying to use Selenium to connect to existing instance of Firefox - the documentation says to use something like this
options=webdriver.FirefoxOptions() options.binary_location = r'C:\Program Files\Mozilla Firefox\\firefox.exe' webdriver_service = Service(r'c:\tmp\geckodriver.exe') driver = webdriver.Firefox(service = webdriver_service, service_args=['--marionette-port', '2828', '--connect-existing']) However, I get the error
driver = webdriver.Firefox(service = webdriver_service, service_args=['--marionette-port', '2828', '--connect-existing']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: WebDriver.__init__() got an unexpected keyword argument 'service_args' I see other questions about "unexpected keyword argument", they say latest versions of Selenium has other ways of passing arguments through Options.
I tried
options.add_argument('--marionette-port') options.add_argument('2828') options.add_argument('--connect-existing') But it still seems to create a new instance of Firefox
I have started firefox with the following arguments
"C:\Program Files\Mozilla Firefox\firefox.exe" -marionette -start-debugger-server 2828
How do I fix this?
These are my versions
Python version
python --version Python 3.12.2 Selenium version
pip show selenium Name: selenium Version: 4.18.1 Geckodriver version
geckodriver --version geckodriver 0.34.0 (c44f0d09630a 2024-01-02 15:36 +0000) Firefox 123.0 (64-bit)
Windows 11
Источник: https://stackoverflow.com/questions/780 ... of-firefox
I am trying to use Selenium to connect to existing instance of Firefox - the documentation says to use something like this
options=webdriver.FirefoxOptions() options.binary_location = r'C:\Program Files\Mozilla Firefox\\firefox.exe' webdriver_service = Service(r'c:\tmp\geckodriver.exe') driver = webdriver.Firefox(service = webdriver_service, service_args=['--marionette-port', '2828', '--connect-existing']) However, I get the error
driver = webdriver.Firefox(service = webdriver_service, service_args=['--marionette-port', '2828', '--connect-existing']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: WebDriver.__init__() got an unexpected keyword argument 'service_args' I see other questions about "unexpected keyword argument", they say latest versions of Selenium has other ways of passing arguments through Options.
I tried
options.add_argument('--marionette-port') options.add_argument('2828') options.add_argument('--connect-existing') But it still seems to create a new instance of Firefox
I have started firefox with the following arguments
"C:\Program Files\Mozilla Firefox\firefox.exe" -marionette -start-debugger-server 2828
How do I fix this?
These are my versions
Python version
python --version Python 3.12.2 Selenium version
pip show selenium Name: selenium Version: 4.18.1 Geckodriver version
geckodriver --version geckodriver 0.34.0 (c44f0d09630a 2024-01-02 15:36 +0000) Firefox 123.0 (64-bit)
Windows 11
Источник: https://stackoverflow.com/questions/780 ... of-firefox
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как подключиться к существующему экземпляру Firefox с помощью селена (Python)
Anonymous » » в форуме Python - 0 Ответы
- 7 Просмотры
-
Последнее сообщение Anonymous
-