Skip to content

Feat : Capture Cross Origin Iframe and new responsive capture features#407

Open
yashmahamulkar-bs wants to merge 9 commits intomasterfrom
PPLT-5077
Open

Feat : Capture Cross Origin Iframe and new responsive capture features#407
yashmahamulkar-bs wants to merge 9 commits intomasterfrom
PPLT-5077

Conversation

@yashmahamulkar-bs
Copy link

This pull request introduces significant enhancements to the responsive DOM capture logic in the Percy class, improving flexibility and configurability for responsive snapshot testing. The main changes include support for per-width height configuration, new environment variable controls, and improved error handling during responsive capture.

Responsive capture improvements:

  • Added support for specifying both width and height for responsive snapshots via the new GetResponsiveWidths method, which fetches width/height pairs from the Percy CLI and replaces the previous width-only logic. (Percy/Percy.cs, Percy/Percy.csR361-R507)
  • Implemented the ability to reload the page between responsive captures when the PERCY_RESPONSIVE_CAPTURE_RELOAD_PAGE environment variable is set, ensuring a fresh DOM state for each snapshot. (Percy/Percy.cs, Percy/Percy.csR517-R554)
  • Introduced support for a minimum snapshot height, controlled by the PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT environment variable and configuration, with fallback logic and error handling for invalid values. (Percy/Percy.cs, [1] [2]

Configuration and environment variable changes:

  • Added two new environment variables, PERCY_RESPONSIVE_CAPTURE_RELOAD_PAGE and PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT, to control page reload and minimum height behavior during responsive capture. (Percy/Percy.cs, Percy/Percy.csR31-R39)

Codebase cleanup and refactoring:

  • Removed the obsolete GetWidthsForMultiDom method and updated all usages to the new width/height-aware logic. (Percy/Percy.cs, Percy/Percy.csL309-L330)
  • Refactored the responsive DOM capture loop to use the new ResponsiveWidth class and handle height per width, including fallback and error handling. (Percy/Percy.cs, Percy/Percy.csR517-R554)

@yashmahamulkar-bs yashmahamulkar-bs requested a review from a team as a code owner March 18, 2026 20:11
@yashmahamulkar-bs yashmahamulkar-bs added the ✨ enhancement New feature or request label Mar 18, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the Percy Selenium .NET SDK’s DOM snapshotting to better support responsive captures (width/height pairs, optional page reloads between captures, and min-height handling) and adds logic intended to serialize cross-origin iframe DOMs.

Changes:

  • Add cross-origin iframe processing during DOM serialization by injecting PercyDOM in frame contexts and attaching frame snapshots to the main snapshot payload.
  • Replace width-only responsive capture logic with a width/height-aware configuration fetched from the Percy CLI, plus optional page reload and min-height computation.
  • Update test expectations for new logged options and adjust test project configuration.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

File Description
package.json Bumps @percy/cli version for new responsive width/height config endpoint support.
Percy/Percy.cs Adds CORS iframe processing and refactors responsive capture to use width/height pairs, reload, and min-height logic.
Percy.Test/Percy.Test.csproj Updates test target framework/lang version and adds content copy for xUnit runner config.
Percy.Test/Percy.Test.cs Updates expected log output and removes responsive snapshot capture test coverage.
Comments suppressed due to low confidence (1)

Percy.Test/Percy.Test.csproj:27

  • The project now targets net10.0 and bumps several PackageReference versions, but Percy.Test/packages.lock.json still contains the old net6.0 lock data and older resolved versions. If lock files are enforced in CI, restore/build may fail. Please update the lock file to match the new target framework and dependencies (or adjust restore settings accordingly).
    <TargetFrameworks>net10.0</TargetFrameworks>
    <LangVersion>9.0</LangVersion>
    <Nullable>enable</Nullable>
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Percy\Percy.csproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.11.1"
      Condition="$(TargetFramework.StartsWith('net4')) AND '$(OS)' == 'Unix'" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
    <PackageReference Include="Selenium.WebDriver" Version="4.27" />
    <PackageReference Include="WebDriverManager" Version="2.16.3" />
    <PackageReference Include="Moq" Version="4.20.72" />
    <PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
    <PackageReference Include="Faker.Net" Version="2.0.154" />
    <PackageReference Include="NSubstitute" Version="5.0.0" />

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants