Skip to content

[dotnet] [bidi] Decouple ScreenshotOrigin in BrowsingContext module #15488

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 1 commit into from
Mar 23, 2025

Conversation

nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Mar 23, 2025

User description

Motivation and Context

Contributes to #15407

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, Tests


Description

  • Decoupled ScreenshotOrigin from CaptureScreenshotOptions to avoid nested DTO types.

  • Updated CaptureScreenshotCommandParameters to use the new ScreenshotOrigin enum.

  • Refactored related test cases to align with the new structure.

  • Improved code clarity and future extensibility by removing nested types.


Changes walkthrough 📝

Relevant files
Enhancement
CaptureScreenshotCommand.cs
Decoupled `ScreenshotOrigin` from `CaptureScreenshotOptions`

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs

  • Replaced nested CaptureScreenshotOptions.ScreenshotOrigin with a
    standalone ScreenshotOrigin enum.
  • Updated CaptureScreenshotCommandParameters to use the standalone
    ScreenshotOrigin.
  • Improved modularity by decoupling nested types.
  • +6/-6     
    Tests
    BrowsingContextTest.cs
    Updated tests for refactored `ScreenshotOrigin` usage       

    dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs

  • Updated test cases to use the standalone ScreenshotOrigin enum.
  • Ensured compatibility with the refactored
    CaptureScreenshotCommandParameters.
  • +2/-2     

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

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    15407 - Fully compliant

    Compliant requirements:

    • Avoid using nested DTO types in the .NET Selenium BiDi implementation
    • Replace nested types with standalone types to prevent name reservation issues
    • Enable future extensibility for static factories and singletons

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

    Test Coverage

    The tests were updated to use the new standalone ScreenshotOrigin enum, but it might be worth adding a specific test that verifies the enum values are correctly serialized/deserialized in the BiDi protocol.

    var screenshot = await context.CaptureScreenshotAsync(new()
    {
        Origin = ScreenshotOrigin.Document,
        Clip = new BoxClipRectangle(5, 5, 10, 10)

    Copy link
    Contributor

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @nvborisenko nvborisenko merged commit ca9de17 into SeleniumHQ:trunk Mar 23, 2025
    10 checks passed
    @nvborisenko nvborisenko deleted the bidi-nested-screenshot branch March 23, 2025 20:20
    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.

    2 participants