Skip to content

Conversation

@nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Mar 8, 2025

User description

https://w3c.github.io/webdriver-bidi/#type-session-UserPromptHandler

Motivation and Context

Contribute to BiDi implementation.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement


Description

  • Introduced UnhandledPromptBehavior for session capabilities in BiDi.

  • Converted CapabilitiesRequest and CapabilityRequest classes to records.

  • Added UserPromptHandler class and UserPromptHandlerType enum for prompt handling.

  • Enhanced session capabilities with better user prompt management.


Changes walkthrough 📝

Relevant files
Enhancement
CapabilitiesRequest.cs
Refactor `CapabilitiesRequest` to record type                       

dotnet/src/webdriver/BiDi/Modules/Session/CapabilitiesRequest.cs

  • Changed CapabilitiesRequest from class to record.
+1/-1     
CapabilityRequest.cs
Update `CapabilityRequest` with prompt handling                   

dotnet/src/webdriver/BiDi/Modules/Session/CapabilityRequest.cs

  • Changed CapabilityRequest from class to record.
  • Replaced WebSocketUrl with UnhandledPromptBehavior.
  • +2/-2     
    UserPromptHandler.cs
    Add `UserPromptHandler` and `UserPromptHandlerType` for prompts

    dotnet/src/webdriver/BiDi/Modules/Session/UserPromptHandler.cs

  • Added new UserPromptHandler record for managing user prompts.
  • Introduced UserPromptHandlerType enum for prompt actions.
  • +42/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @qodo-code-review
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Removed Property

    The WebSocketUrl property was removed without replacement. Verify this property is no longer needed or used elsewhere in the codebase.

    public UserPromptHandler? UnhandledPromptBehavior { get; set; }

    @qodo-code-review
    Copy link
    Contributor

    qodo-code-review bot commented Mar 8, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Learned
    best practice
    Initialize properties with meaningful default values to provide predictable behavior when not explicitly set

    The UserPromptHandler record has nullable enum properties that could benefit
    from having default values. Consider initializing the Default property with a
    meaningful default value like UserPromptHandlerType.Dismiss to provide
    predictable behavior when not explicitly set.

    dotnet/src/webdriver/BiDi/Modules/Session/UserPromptHandler.cs [22-35]

     public record UserPromptHandler
     {
         public UserPromptHandlerType? Alert { get; set; }
     
         public UserPromptHandlerType? BeforeUnload { get; set; }
     
         public UserPromptHandlerType? Confirm { get; set; }
     
    -    public UserPromptHandlerType? Default { get; set; }
    +    public UserPromptHandlerType? Default { get; set; } = UserPromptHandlerType.Dismiss;
     
         public UserPromptHandlerType? File { get; set; }
     
         public UserPromptHandlerType? Prompt { get; set; }
     }
    • Apply this suggestion
    Suggestion importance[1-10]: 6
    Low
    • Update

    @nvborisenko nvborisenko merged commit 80feb18 into SeleniumHQ:trunk Mar 8, 2025
    9 of 10 checks passed
    @nvborisenko nvborisenko deleted the bidi-unhandledPromptBehavior branch March 8, 2025 17:34
    sandeepsuryaprasad pushed a commit to sandeepsuryaprasad/selenium that referenced this pull request Mar 23, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant