Skip to content

[py] Call service.stop() when session can't be started #15636

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

Merged
merged 12 commits into from
Apr 18, 2025

Conversation

cgoldberg
Copy link
Contributor

@cgoldberg cgoldberg commented Apr 17, 2025

User description

🔗 Related Issues

This is a fix for #15634 (for Python only)

💥 What does this PR do?

When a driver fails to start the browser, SessionNotCreatedException is raised. This PR fixes it so the underlying driver service is explicitly stopped when any exception occurs.

I added tests for this for Chrome, Edge, and Firefox

🔄 Types of changes

  • Bug fix (backwards compatible)

PR Type

Bug fix


Description

  • Ensures service.stop() is called when session creation fails.

  • Adds exception handling for Exception in start_session.

  • Adds tests for this


Changes walkthrough 📝

Relevant files
Bug fix
webdriver.py
Add exception handling for session creation failure           

py/selenium/webdriver/remote/webdriver.py

  • Added handling for SessionNotCreatedException in start_session.
  • Ensured service.stop() is called when session creation fails.
  • Improved error handling during session initialization.
  • +8/-3     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @selenium-ci selenium-ci added the C-py Python Bindings label Apr 17, 2025
    Copy link
    Contributor

    qodo-merge-pro bot commented Apr 17, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🔒 No security concerns identified

    Copy link
    Contributor

    qodo-merge-pro bot commented Apr 17, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @cgoldberg cgoldberg force-pushed the py-stop-session-not-created branch from 0d751ff to 27c9166 Compare April 18, 2025 02:48
    @cgoldberg cgoldberg merged commit 8f40a8f into SeleniumHQ:trunk Apr 18, 2025
    17 checks passed
    @cgoldberg cgoldberg deleted the py-stop-session-not-created branch April 18, 2025 16:30
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants