mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.2k stars 1.52k forks source link

Can not attach to already-running Firefox instance #2020

Closed hkfsc closed 2 years ago

hkfsc commented 2 years ago

System

Testcase

firefox.exe -new-instance -no-remote start-debugger-server 6000 geckodriver.exe --marionette-port 6000 --connect-existing

from selenium import webdriver
d = webdriver.remote.webdriver.WebDriver(command_executor='http://localhost:4444')
d

Stacktrace

File c:\users\user\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:247, in ErrorHandler.check_response(self, response)
    245         alert_text = value['alert'].get('text')
    246     raise exception_class(message, screen, stacktrace, alert_text)  # type: ignore[call-arg]  # mypy is not smart enough here
--> 247 raise exception_class(message, screen, stacktrace)

TimeoutException: Message: missing field `marionetteProtocol` at line 1 column 263

Trace-level log

1652538393811   geckodriver     INFO    Listening on 127.0.0.1:4444
1652538402923   webdriver::server       DEBUG   -> POST /session {"capabilities": {"firstMatch": [{}], "alwaysMatch":{"browserName": "firefox", "acceptInsecureCerts": true, "moz:debuggerAddress": true, "pageLoadStrategy": "normal"}}}
1652538402924   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1
1652538402926   geckodriver::marionette TRACE   Retrying in 100ms
1652538402993   geckodriver::marionette TRACE   Retrying in 100ms
1652538403060   geckodriver::marionette TRACE   Retrying in 100ms
1652538403126   geckodriver::marionette TRACE   Retrying in 100ms
1652538403192   geckodriver::marionette TRACE   Retrying in 100ms
1652538403258   geckodriver::marionette TRACE   Retrying in 100ms
1652538403325   geckodriver::marionette TRACE   Retrying in 100ms
...
1652538530749   webdriver::server       DEBUG   <- 500 Internal Server Error {"value":{"error":"timeout","message":"missing field `marionetteProtocol` at line 1 column 263","stacktrace":""}}
whimboo commented 2 years ago

start-debugger-server is not the right command line argument for Marionette. What you want to use instead is --marionette.