Skip to content

Added Video Recording for Playwright#4148

Merged
Maheshkale447 merged 7 commits into
masterfrom
Enhancement/AddRecordVideoFeatureToWebAgents
Apr 1, 2025
Merged

Added Video Recording for Playwright#4148
Maheshkale447 merged 7 commits into
masterfrom
Enhancement/AddRecordVideoFeatureToWebAgents

Conversation

@rathimayur

@rathimayur rathimayur commented Mar 28, 2025

Copy link
Copy Markdown
Contributor

Added code to enable Video recording in Playwright
Added code open existing selected directory using VE Expression

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

  • New Features

    • Introduced video recording configuration options in the settings, including a toggle to enable recording, directory selection, and resolution adjustments.
    • Enhanced browser automation to support video recording during sessions, with improved error handling and logging for a smoother testing experience.
    • Improved folder navigation by dynamically setting the initial directory based on user input.
  • Bug Fixes

    • Added error handling for video recording dependency installation to prevent failures during setup.

@coderabbitai

coderabbitai Bot commented Mar 28, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request introduces functionality for video recording configuration within the WebAgentConfigEditPage and related components. It adds UI elements such as checkboxes and input fields for video settings and implements event handlers to manage these settings. The backend code integrates these configurations into the Playwright driver, manages the installation of the necessary ffmpeg dependency, and enhances logging for video file paths upon browser tab closure. Additionally, improvements to folder browsing logic ensure user-defined initial directories.

Changes

File(s) Summary
Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml
Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs
Added UI elements (StackPanels, CheckBox, UCValueExpression controls) and event handlers for configuring video recording (directory path, width, height) in the web agent config page.
Ginger/Ginger/ValueExpression/UCValueExpression.xaml.cs Enhanced the BrowseButton_Click method to determine the initial folder for the browser dialog based on the solution path and user input, with added null checks.
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserTab.cs
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightNonPersistentBrowser.cs
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightPersistentBrowser.cs
Integrated video recording support into Playwright components by adding new properties, updating methods to include video recording options, centralizing dependency installation with improved error messaging (ffmpeg), and logging video file paths upon browser tab closure.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant UI as WebAgentConfigEditPage
    participant PD as PlaywrightDriver
    participant PB as PlaywrightBrowser
    participant BC as BrowserContext
    participant R as Reporter

    U->>UI: Toggle "Enable Video Recording" checkbox
    UI->>UI: Invoke xEnableVideoRecordingCheckBox_Click
    UI->>PD: Update video recording settings (dir, width, height)
    PD->>PB: Build options with video recording parameters
    PB->>PB: ExecutePlaywrightInstallation("ffmpeg")
    alt Installation fails
       PB->>PB: Disable video recording and log error
    else Installation succeeds
       PB->>BC: Launch browser context with video options
    end
    BC-->>R: On close, retrieve and log video file path
Loading

Possibly related PRs

Suggested reviewers

  • Maheshkale447

Poem

I’m hopping through the code all day,
Setting video paths along the way.
With panels and checkboxes shining bright,
I record each frame in pure delight.
From ffmpeg to logs, my work’s a fun display!
A rabbit’s cheer to code that plays!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightPersistentBrowser.cs (1)

131-149: 🧹 Nitpick (assertive)

Video recording configuration properly implemented.

The implementation initializes default values for RecordVideoSize and only overrides them when video recording is enabled. This ensures backward compatibility and prevents null reference exceptions.

One minor optimization: The check for _options != null on line 134 is redundant as it was already checked on line 126. Consider removing this redundant check.

-if (_options != null && _options.EnableVideoRecording)
+if (_options.EnableVideoRecording)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 645945c and 704f8ff.

📒 Files selected for processing (8)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml (1 hunks)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (7 hunks)
  • Ginger/Ginger/ValueExpression/UCValueExpression.xaml.cs (1 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs (3 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserTab.cs (1 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightNonPersistentBrowser.cs (4 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightPersistentBrowser.cs (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (2)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4107
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:763-831
Timestamp: 2025-03-25T06:06:39.942Z
Learning: In the Ginger project, prefer readable implementations with fixed values over configurable approaches when implementing UI automation features like drawing, unless configurability is specifically required.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4107
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:664-705
Timestamp: 2025-03-25T06:06:39.942Z
Learning: In the Ginger automation framework, exceptions in lower-level browser element operations are handled by their parent methods, which have more context about the operation being performed. Therefore, catch-and-rethrow without additional context is acceptable in the element-level methods.
🧬 Code Definitions (3)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightNonPersistentBrowser.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs (1)
  • ExecutePlaywrightInstallation (80-87)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightPersistentBrowser.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs (1)
  • ExecutePlaywrightInstallation (80-87)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs (3)
  • PlaywrightBrowser (24-88)
  • PlaywrightBrowser (55-63)
  • Options (29-42)
🔇 Additional comments (13)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightNonPersistentBrowser.cs (2)

77-88: Good implementation of dependency handling for video recording.

The code correctly adds functionality to install the ffmpeg dependency when video recording is enabled. The error handling is robust - if the installation fails, it appropriately logs the error and falls back by disabling video recording rather than allowing the entire process to fail.

The code appropriately leverages the existing ExecutePlaywrightInstallation method from PlaywrightBrowser.cs.


144-158:

Details

❓ Verification inconclusive

Video recording configuration properly implemented.

This implementation correctly initializes and applies the video recording settings to the browser context options. The conditional check ensures video recording is only configured when enabled.

One suggestion: consider handling the case where RecordVideoDir is empty but video recording is enabled, as this might cause runtime issues.

Run the following script to check if there are any validation checks for empty video directory elsewhere in the codebase:


🏁 Script executed:

#!/bin/bash
# Check if there's validation for empty video directory in related files
rg -A 3 -B 3 "RecordVideoDir" --glob "*.cs"

Length of output: 13609


Video Recording Directory Validation in Non-Persistent Browser

  • The video recording settings are correctly wired in the browser context options.
  • UI flow in the codebase (e.g., in WebAgentConfigEditPage.xaml.cs) already ensures that an empty video directory value is replaced with the default (~\Documents\VideoRecordings).
  • However, since PlaywrightNonPersistentBrowser.cs simply assigns _options.RecordVideoDir without an extra check, please verify that all instantiations of _options (including any programmatic ones outside the UI) always provide a valid non-empty directory. If there's any chance of missing validation, consider adding a safeguard here.
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightPersistentBrowser.cs (1)

85-96: Proper implementation of dependency installation for video recording.

The code correctly checks if video recording is enabled, attempts to install the required ffmpeg dependency, and gracefully handles failures by disabling video recording and logging an error. This is a robust implementation that prevents failures in the dependency installation from breaking the entire functionality.

Ginger/Ginger/ValueExpression/UCValueExpression.xaml.cs (2)

121-127: Enhanced folder selection feature with path expansion.

The implementation successfully adds the ability to use relative paths starting with ~\ when browsing for folders, which is expanded to the solution's directory. This provides better user experience by allowing users to specify relative paths that will be correctly resolved.

Good defensive programming with the null check before performing string operations on ValueTextBox.Text.


132-134: Improved folder browser configuration.

The implementation now sets the initial directory based on the user input or the expanded path, which enhances usability by opening the dialog in the expected location. Also, enabling the "New Folder" button is a good addition for scenarios where users need to create directories on the fly.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2)

114-119: Good implementation of path resolution for video recording directory.

The code correctly handles relative paths for video recording by replacing the tilde prefix with the actual solution folder path. This ensures that video files are stored in a consistent location relative to the project, making it more portable across different environments.


126-128: LGTM: Video recording configuration properly set in browser options.

These lines correctly configure the video recording settings in the PlaywrightBrowser options object, ensuring that the user's preferences are properly applied when starting the browser.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs (3)

27-27: LGTM: Added helpful error message constant.

Adding this constant helps maintain consistency in error messages throughout the codebase.


39-41: LGTM: Well-defined properties for video recording configuration.

These properties properly encapsulate the video recording settings needed by the PlaywrightBrowser.


77-86: Good refactoring of installation logic.

Extracting the installation logic into a separate static method improves code reusability and readability. The improved error message now includes the component name and exit code, which will help with troubleshooting.

Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (3)

68-103: Good implementation of path normalization for video directory.

The code effectively handles path normalization, ensuring that paths are represented consistently using the "~" prefix for paths relative to the solution directory. This improves portability and readability.


398-402: LGTM: Proper event handling setup for the video directory textbox.

Event handlers are correctly set up to manage the behavior of the video directory text box, and the initial enabled state of controls is set based on the checkbox state.


532-535: LGTM: Good UI responsiveness for the video recording checkbox.

The event handler properly enables/disables the video recording controls based on the checkbox state, providing immediate feedback to the user.

Comment thread Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 28, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 704f8ff and 9bbf0a2.

📒 Files selected for processing (2)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (7 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (2)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4107
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:763-831
Timestamp: 2025-03-25T06:06:39.942Z
Learning: In the Ginger project, prefer readable implementations with fixed values over configurable approaches when implementing UI automation features like drawing, unless configurability is specifically required.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4107
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:664-705
Timestamp: 2025-03-25T06:06:39.942Z
Learning: In the Ginger automation framework, exceptions in lower-level browser element operations are handled by their parent methods, which have more context about the operation being performed. Therefore, catch-and-rethrow without additional context is acceptable in the element-level methods.
🧬 Code Definitions (2)
Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (1)
  • PlaywrightDriver (53-2007)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (1)
  • eBrowserType (504-507)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs (3)
  • PlaywrightBrowser (24-88)
  • PlaywrightBrowser (55-63)
  • Options (29-42)
🔇 Additional comments (12)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (1)

649-668: New video recording properties look consistent.

These property definitions correctly associate user-configurable attributes, default values, and descriptive text for video recording. The descriptive text for width and height is correct (no mismatch).

Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (11)

22-22: Import statement is appropriate.

This addition aligns with the usage of PlaywrightDriver references in this file.


50-50: Initialization call is fine.

Calling InitializeComponent() in the constructor is standard practice for WPF pages.


68-71: LostFocus event handler looks good.

This method simply delegates to ReplaceSolutionDirPathInVideoDirPath, which helps maintain relative paths.


72-93: Path normalization logic is sensible.

Using "~\\" as a placeholder for the solution folder and restoring the default path when empty is a good approach. Ensure edge cases around partial matches of solutionFolder remain acceptable.


95-103: TextChanged event smoothly updates the path.

Replacing the solution path on larger edits helps maintain consistent relative paths. The condition (textChange.AddedLength > 1 || textChange.RemovedLength > 1) is a reasonable heuristic.


321-338: Binding video-recording parameters is correct.

These additions allow the UI to manage new Playwright-specific properties (EnableVideoRecording, RecordVideoDir, VideoHeight, and VideoWidth).


387-387: Advanced settings visibility adjustment is aligned with Playwright usage.

No concerns here.


389-389: Hiding RemoteWebDriverUrl for Playwright.

Makes sense since remote WebDriver setups are more Selenium-centric.


398-403: Displaying video recording panel & attaching events.

Enabling the panel only when video recording is checked is a logical UI flow.


404-407: Hiding video panel for non-Playwright drivers is consistent.

Collapsing the panel ensures a clean UI for drivers lacking video-recording features.


531-535: Checkbox click toggles video-panel controls.

This short method cleanly updates the IsEnabled state based on the checkbox.

Comment thread Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 28, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2)

114-119: ⚠️ Potential issue

Fix path replacement not being applied to final options.

The modified recordVideoDir is never reassigned back to the RecordVideoDir property. When you later use RecordVideoDir in the options at line 127, it still contains the original path with the ~\ prefix if it was present.

Add this line after the path replacement:

string recordVideoDir = RecordVideoDir;
if (recordVideoDir != null && recordVideoDir.StartsWith(@"~\"))
{
    string solutionFolder = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.Solution.Folder;
    recordVideoDir = recordVideoDir.Replace(@"~\", solutionFolder, StringComparison.InvariantCultureIgnoreCase);
+   RecordVideoDir = recordVideoDir; // Ensure the updated path is used in options
}

663-667: ⚠️ Potential issue

Fix inconsistency in the VideoWidth property description and add a default value.

The description incorrectly refers to height instead of width. Also, the property has an empty string default value, which is unusual for an integer property.

[UserConfigured]
-[UserConfiguredDefault("")]
+[UserConfiguredDefault("1280")]
-[UserConfiguredDescription("The height in pixels of video recording")]
+[UserConfiguredDescription("The width in pixels of video recording")]
public int VideoWidth { get; set; }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9bbf0a2 and 29c68b4.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs (3)
  • PlaywrightBrowser (24-88)
  • PlaywrightBrowser (55-63)
  • Options (29-42)
🔇 Additional comments (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2)

126-128: Ensure video recording options are properly configured.

The code correctly adds video recording settings to the browser options, including the recording directory, whether recording is enabled, and the video dimensions.


653-657: LGTM! Enable video recording property correctly implemented.

The property is properly configured with a default value of "false" which is a safe default requiring explicit opt-in for video recording.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (1)

180-188: 🧹 Nitpick (assertive)

Log video file paths when browser closes.

Consider adding logging for video file paths when a browser tab is closed. This would help users locate the video recordings more easily, especially if they're using the default path with environment variables.

private Task OnBrowserClose(IBrowser closedBrowser)
{
    if (closedBrowser == _browser)
    {
        _browser = null;
+       if (EnableVideoRecording && !string.IsNullOrEmpty(RecordVideoDir))
+       {
+           Reporter.ToLog(eLogLevel.INFO, $"Video recording saved to: {RecordVideoDir}");
+       }
    }

    return Task.CompletedTask;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29c68b4 and 740d123.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs (3)
  • PlaywrightBrowser (24-88)
  • PlaywrightBrowser (55-63)
  • Options (29-42)
🔇 Additional comments (5)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (5)

114-119: Ensure updated path reflects in final options.

Within this block, the local variable recordVideoDir is changed if it starts with ~\, but that updated value is never reassigned back to RecordVideoDir. As a result, the line in the returned PlaywrightBrowser.Options that sets RecordVideoDir = recordVideoDir is effectively ignoring the transformed path.

A possible fix:

string recordVideoDir = RecordVideoDir;
if (recordVideoDir != null && recordVideoDir.StartsWith(@"~\"))
{
    string solutionFolder = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.Solution.Folder;
    recordVideoDir = recordVideoDir.Replace(@"~\", solutionFolder, StringComparison.InvariantCultureIgnoreCase);
}

+ // Reassign the property to capture the updated path
+ RecordVideoDir = recordVideoDir;

132-134: LGTM - Video recording configuration is correctly set in options.

The implementation properly sets the video recording options in the browser options object.


655-658: Consider adding path validation for video directory.

The RecordVideoDir is properly configured with a default path, but there's no validation to ensure the path is accessible and writable. Consider adding runtime validation when video recording is enabled.

Example validation:

if (EnableVideoRecording && !string.IsNullOrEmpty(RecordVideoDir))
{
    string dirPath = RecordVideoDir;
    if (dirPath.StartsWith(@"~\"))
    {
        string solutionFolder = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.Solution.Folder;
        dirPath = dirPath.Replace(@"~\", solutionFolder, StringComparison.InvariantCultureIgnoreCase);
    }
    
    try
    {
        Directory.CreateDirectory(dirPath);
    }
    catch (Exception ex)
    {
        Reporter.ToLog(eLogLevel.ERROR, $"Failed to create video recording directory: {dirPath}", ex);
        EnableVideoRecording = false;
    }
}

667-668: Fix inconsistency in the VideoHeight property description.

The description for VideoHeight incorrectly states "The height in pixels" instead of "The width in pixels".

-[UserConfiguredDescription("The height in pixels of video recording")]
+[UserConfiguredDescription("The height in pixels of video recording")]
public int VideoHeight { get; set; }

665-668: Add a default value for VideoHeight.

The VideoHeight property has an empty string default value, which is unusual for an integer property. Consider setting a reasonable default dimension like 720p.

[UserConfigured]
-[UserConfiguredDefault("")]
+[UserConfiguredDefault("720")]
[UserConfiguredDescription("The height in pixels of video recording")]
public int VideoHeight { get; set; }

@Maheshkale447
Maheshkale447 merged commit 6273b65 into master Apr 1, 2025
@Maheshkale447
Maheshkale447 deleted the Enhancement/AddRecordVideoFeatureToWebAgents branch April 1, 2025 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants