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

After manually quitting, setting a new driver fails #206

Closed
SimonBaars opened this issue Mar 19, 2020 · 3 comments
Closed

After manually quitting, setting a new driver fails #206

SimonBaars opened this issue Mar 19, 2020 · 3 comments
Labels

Comments

@SimonBaars
Copy link
Contributor

Selene version: 2.0.0a21

I quit my current driver using browser.quit().
Then, I create a new driver and set it, which runs the following method:

@driver.setter
    def driver(self, value: WebDriver):
        stored = self._source.value
        is_another_driver = on_error_return_false(lambda: value.session_id != stored.session_id)

        if is_another_driver:
            stored.quit()  # todo: can quit raise exception? handle then...

        self._source.put(value)

        self.browser_name = value and value.name  # overwrites default browser_name

The problem is, that the quit() method doesn't remove the driver object, and thus the session id will differ. Because of this, is_another_driver will be True and thus stored.quit() will fail throwing a selenium.common.exceptions.WebDriverException: Message: Session timed out or not found.

Suggested fix:
Either change the condition for is_another_driver or make quit() nullify the session_id.

@yashaka
Copy link
Owner

yashaka commented Mar 19, 2020

Wow! Thank you for the issue and the fix suggestion. Please monkey patch selene in your code with a fix, you already know. And I fix it in the next version. Will try to do this asap in nearest days!

@yashaka yashaka added the bug label Mar 19, 2020
@SimonBaars
Copy link
Contributor Author

I think setting the _source of SharedConfig to None is the best way to solve this because otherwise, it would point to an old source. I opened a PR with my suggestion.

@yashaka
Copy link
Owner

yashaka commented Mar 19, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants