Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot attach to existing session #104

Closed
alexmorozov opened this issue Jun 21, 2016 · 9 comments
Closed

Cannot attach to existing session #104

alexmorozov opened this issue Jun 21, 2016 · 9 comments

Comments

@alexmorozov
Copy link

alexmorozov commented Jun 21, 2016

Hi guys and sorry if this issue doesn't belong here.

After upgrading to geckodriver I'm unable to reuse my Selenium's sessions. Here's my setup:
I have a start_browser.py script, which launches a Fireofx instance and prints a port to connect to, like:

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
browser = webdriver.Firefox(capabilities=firefox_capabilities)
print browser.service.port
wait_forever()

... and another script, which tries to connect to the existing instance via Remote driver:

caps = DesiredCapabilities.FIREFOX
caps['marionette'] = True
driver = webdriver.Remote(
            command_executor='http://localhost:{port}'.format(port=port),
            desired_capabilities=caps)

But it seems to be trying to launch a new session, and failing with a message:

selenium.common.exceptions.WebDriverException: Message: Session is already started

Is there an ability to just attach to the existing session, like in previous versions of Selenium? Or is this an intended behaviour of geckodriver?

@alexmorozov
Copy link
Author

As I can't clearly decide whether this is a bug or my lack of knowledge, I've asked the same question on SO: http://stackoverflow.com/questions/37963785/cannot-attach-to-existing-selenium-session-with-a-geckodriver .

@andreastt
Copy link
Contributor

@alexmorozov This is probably a real issue. I haven’t used Selenium to attach to existing sessions before, so I don’t yet know in what layer there is a problem.

@alexmorozov
Copy link
Author

@andreastt , I suspect geckodriver is a culprit here. Simply because on earlier FF versions with legacy driver I had been able connect to an existing session in a way I described above. If you kindly point me to a legacy driver's codebase, I'd try to look into it and come up with some specific suggestions.

@andreastt
Copy link
Contributor

@alexmorozov
Copy link
Author

Okay, I think I have overestimated my skills. Feeling completely lost in a bizarre mix of JS, Python and Java. But I was able to reconnect to my browser by cutting the new session creation out of the webdriver:

class MyCustomShinyRemote(webdriver.Remote):
    def start_session(self, desired_capabilities, browser_profile=None):
        # Skip the NEW_SESSION command issued by the stock driver
        # and set only some required attributes
        self.w3c = True

So now I can connect to the browser and now it complains that Message: POST /session/bd65aed2-bd03-4b40-a422-f710db291adf/moveto did not match a known command. Am I on a right track and geckodriver doesn't support mouse movement yet, or am I facing the consequences of my reckless driver surgery?

@andreastt
Copy link
Contributor

I think what you’re running into here is reconnecting to a previous session.

The /session/{session id}/moveto endpoint does not exist in WebDriver-conformant remote ends, however. We will need to do a shim for this in the Selenium Python client bindings. Would you mind filing an issue with Selenium on that?

@alexmorozov
Copy link
Author

Sure thing. Actually there is already an issue there: SeleniumHQ/selenium#2285 . And they seem to be waiting to clear some things with you. :)

@alexmorozov
Copy link
Author

Closing this one as the behaviour seems to should be fixed in Selenium itself. See the SO post for how to work around it for the time being.

@lock
Copy link

lock bot commented Aug 17, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants