Skip to content

Scrollable screen-shot support added for mobile device#4232

Merged
Maheshkale447 merged 7 commits into
masterfrom
BugFix/VisualTestingForMobile
Jun 16, 2025
Merged

Scrollable screen-shot support added for mobile device#4232
Maheshkale447 merged 7 commits into
masterfrom
BugFix/VisualTestingForMobile

Conversation

@prashelke

@prashelke prashelke commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

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 full-page screenshot capture for mobile devices, including automatic scrolling and merging of screenshots to create a complete page image.
    • Added functionality to hide sticky elements during screenshot capture for improved image quality.
  • Improvements

    • Enhanced screenshot handling for mobile drivers, ensuring more accurate and comprehensive visual testing.
    • Improved code consistency and exception handling for a smoother user experience.

@coderabbitai

coderabbitai Bot commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update enhances screenshot functionality for mobile automation by introducing full-page screenshot capabilities in the GenericAppiumDriver class and updating the TrackVRT method in VRTAnalyzer to use this new method when appropriate. Additional helper methods for scrolling, merging images, and converting screenshots are also implemented.

Changes

File(s) Change Summary
.../ActionsLib/UI/VisualTesting/VRTAnalyzer.cs Refactored screenshot capture in TrackVRT to use new private method GetScreenshot() which calls full-page capture for Appium drivers; added using directive.
.../Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs Added full-page screenshot capability with scrolling, cropping, duplicate detection, and merging; added methods to scroll, convert screenshots to bytes, and merge images; improved formatting and exception handling.

Sequence Diagram(s)

sequenceDiagram
    participant VRTAnalyzer
    participant Driver (GenericAppiumDriver or Other)
    participant AppiumDriver

    VRTAnalyzer->>Driver: TrackVRT()
    alt Driver is GenericAppiumDriver and full-page needed
        Driver->>Driver: CaptureFullPageCroppedScreenshot()
        loop While page is scrollable and no duplicate
            Driver->>AppiumDriver: ScrollDown()
            Driver->>Driver: Capture and crop screenshot
        end
        Driver->>Driver: MergeScreenshotsVertically()
        Driver->>VRTAnalyzer: Return full-page screenshot
    else
        Driver->>Driver: GetScreenShot()
        Driver->>VRTAnalyzer: Return screenshot
    end
Loading

Possibly related PRs

Suggested reviewers

  • Maheshkale447

Poem

A rabbit hopped through code so wide,
Stitching screenshots, side by side.
Scrolling down with gentle care,
Cropping bits with flair to spare.
Now a mobile page in full view,
Thanks to Ginger’s clever crew!
🐇📱✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch BugFix/VisualTestingForMobile
  • Post Copyable Unit Tests in Comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@prashelke
prashelke requested a review from Maheshkale447 June 16, 2025 09:16

@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: 7

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6692036 and 72f2fef.

📒 Files selected for processing (2)
  • Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (3 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (38 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (4)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4188
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:22-23
Timestamp: 2025-04-25T13:29:45.059Z
Learning: The `using Amdocs.Ginger.Repository;` statement in Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs is necessary as it provides access to the `ObservableList<>` class which is used throughout the file for collections of RunSetConfig, AnalyzerItemBase, and ApplicationPOMModel objects.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-03-20T11:10:30.816Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-03-20T11:10:33.780Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4188
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:22-23
Timestamp: 2025-04-25T13:29:45.059Z
Learning: The `using Amdocs.Ginger.Repository;` statement in Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs is necessary as it imports the ObservableList<> class which is used throughout the file.
🧬 Code Graph Analysis (1)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (2)
  • GenericAppiumDriver (82-5323)
  • GenericAppiumDriver (258-261)

Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs Outdated
Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs Outdated
Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs
Comment thread Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs Outdated
Comment thread Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 16, 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 (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (1)

1708-1720: Guard clause must come before using images[0]

width = images[0].Width is executed before verifying that images is non-null and non-empty, leading to an IndexOutOfRangeException when CaptureFullPageCroppedScreenshot returns zero frames.

- int totalHeight = images.Sum(img => img.Height);
- int width = images[0].Width;
- if (images == null || images.Count == 0)
+ if (images == null || images.Count == 0)
     throw new ArgumentException("images collection must contain at least one Bitmap", nameof(images));
+ int totalHeight = images.Sum(img => img.Height);
+ int width = images[0].Width;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 72f2fef and 9f38801.

📒 Files selected for processing (2)
  • Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (4 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (38 hunks)
🧰 Additional context used
🧠 Learnings (2)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (6)
Learnt from: prashelke
PR: Ginger-Automation/Ginger#4232
File: Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs:219-226
Timestamp: 2025-06-16T10:13:01.319Z
Learning: In VRTAnalyzer.cs for the GenericAppiumDriver class, the mAct.IsFullPageScreenshot flag is not applicable and should not be used to control screenshot behavior. GenericAppiumDriver always uses CaptureFullPageCroppedScreenshot() method regardless of the IsFullPageScreenshot flag setting.
Learnt from: prashelke
PR: Ginger-Automation/Ginger#4232
File: Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs:19-22
Timestamp: 2025-06-16T09:52:40.854Z
Learning: The `GenericAppiumDriver` class is located in the `Amdocs.Ginger.CoreNET` namespace, not in a namespace that matches its file path structure. File paths don't always correspond to namespace declarations in this codebase.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4188
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:22-23
Timestamp: 2025-04-25T13:29:45.059Z
Learning: The `using Amdocs.Ginger.Repository;` statement in Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs is necessary as it provides access to the `ObservableList<>` class which is used throughout the file for collections of RunSetConfig, AnalyzerItemBase, and ApplicationPOMModel objects.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-03-20T11:10:30.816Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-03-20T11:10:33.780Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4188
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:22-23
Timestamp: 2025-04-25T13:29:45.059Z
Learning: The `using Amdocs.Ginger.Repository;` statement in Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs is necessary as it imports the ObservableList<> class which is used throughout the file.
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (1)

undefined

<retrieved_learning>
Learnt from: prashelke
PR: #4232
File: Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs:219-226
Timestamp: 2025-06-16T10:13:01.319Z
Learning: In VRTAnalyzer.cs for the GenericAppiumDriver class, the mAct.IsFullPageScreenshot flag is not applicable and should not be used to control screenshot behavior. GenericAppiumDriver always uses CaptureFullPageCroppedScreenshot() method regardless of the IsFullPageScreenshot flag setting.
</retrieved_learning>

🧬 Code Graph Analysis (2)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (2)
  • GenericAppiumDriver (82-5278)
  • GenericAppiumDriver (258-261)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (3)
Ginger/GingerCoreNET/ActionsLib/UI/Mobile/ActMobileDevice.cs (1)
  • ActMobileDevice (30-668)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (8)
  • Bitmap (2003-2035)
  • Bitmap (9544-9625)
  • Bitmap (9627-9660)
  • Bitmap (9701-9705)
  • Bitmap (9848-9876)
  • Bitmap (9877-9881)
  • Bitmap (9883-9964)
  • Size (10876-10879)
Ginger/GingerCoreCommon/Actions/Act.cs (1)
  • AddOrUpdateReturnParamActual (1305-1332)
🔇 Additional comments (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (1)

1731-1740: HideStickyElements silently no-ops on native views

IJavaScriptExecutor only works when the driver context is web; on native pages the cast throws and the catch swallows the error.
Verify driver.Context.StartsWith("WEBVIEW") (Android) / driver.Context == "WEBVIEW" (iOS) before executing the script, or skip this step for non-web contexts to avoid pointless try/catch overhead.

Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (1)

219-230: Nice cleanup – duplicated screenshot logic centralised

Switching to GetScreenshot() eliminates the two previously diverging code blocks and keeps baseline/non-baseline paths in sync. 👍
Please just double-check that every call site copes with a possible null return (see follow-up comment).

Comment thread Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs Outdated
Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs
Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 16, 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: 5

🔭 Outside diff range comments (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (1)

4324-4330: Parameter shadowing & path logic in SetFilePath

Local variable fileName shadows method parameter FileName, making the ternary
expression hard to follow and producing unexpected paths when a directory is
passed. Consider simplifying:

-                string fileName = Path.GetFileName(FilePath);
-                string targetFile = string.IsNullOrEmpty(fileName) ? Path.Combine(FilePath, $"{FileName}_{timestamp}.{FileType}") : $"{FilePath}.{FileType}";
+                string baseName = Path.GetFileName(FilePath);
+                string targetFile = string.IsNullOrEmpty(baseName)
+                    ? Path.Combine(FilePath, $"{FileName}_{timestamp}.{FileType}")
+                    : Path.Combine(Path.GetDirectoryName(FilePath)!, $"{baseName}_{timestamp}.{FileType}");
♻️ Duplicate comments (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (2)

1683-1689: Heavy Base-64 hashing was already flagged earlier

Re-encoding every crop to PNG + Base64 is CPU/memory expensive on long pages.
Previous review suggested a raw-pixel MD5/SHA-1 or lightweight checksum.
No functional change was made; consider addressing before merge to avoid slow tests.


1709-1715: Null-guard placed after first use – can crash on empty list

width = images[0].Width executes before the empty-collection check,
so images.Count == 0 still throws IndexOutOfRangeException.

-            int totalHeight = images.Sum(img => img.Height);
-            int width = images[0].Width;
-            if (images == null || images.Count == 0)
+            if (images == null || images.Count == 0)
+                throw new ArgumentException("images collection must contain at least one Bitmap", nameof(images));
+
+            int totalHeight = images.Sum(img => img.Height);
+            int width = images[0].Width;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9f38801 and 9b9ff7a.

📒 Files selected for processing (2)
  • Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (4 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (38 hunks)
🧰 Additional context used
🧠 Learnings (2)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (7)
Learnt from: prashelke
PR: Ginger-Automation/Ginger#4232
File: Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs:219-226
Timestamp: 2025-06-16T10:13:01.319Z
Learning: In VRTAnalyzer.cs for the GenericAppiumDriver class, the mAct.IsFullPageScreenshot flag is not applicable and should not be used to control screenshot behavior. GenericAppiumDriver always uses CaptureFullPageCroppedScreenshot() method regardless of the IsFullPageScreenshot flag setting.
Learnt from: prashelke
PR: Ginger-Automation/Ginger#4232
File: Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs:19-22
Timestamp: 2025-06-16T09:52:40.854Z
Learning: The `GenericAppiumDriver` class is located in the `Amdocs.Ginger.CoreNET` namespace, not in a namespace that matches its file path structure. File paths don't always correspond to namespace declarations in this codebase.
Learnt from: prashelke
PR: Ginger-Automation/Ginger#4232
File: Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs:19-22
Timestamp: 2025-06-16T10:37:13.024Z
Learning: In Ginger codebase, both `using amdocs.ginger.GingerCoreNET;` and `using Amdocs.Ginger.CoreNET;` are valid and serve different purposes. The first (lowercase) contains the WorkSpace class and related workspace functionality, while the second (proper case) contains drivers like GenericAppiumDriver and other core functionality. Both may be required in files that use types from both namespaces.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4188
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:22-23
Timestamp: 2025-04-25T13:29:45.059Z
Learning: The `using Amdocs.Ginger.Repository;` statement in Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs is necessary as it provides access to the `ObservableList<>` class which is used throughout the file for collections of RunSetConfig, AnalyzerItemBase, and ApplicationPOMModel objects.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-03-20T11:10:30.816Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-03-20T11:10:33.780Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4188
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:22-23
Timestamp: 2025-04-25T13:29:45.059Z
Learning: The `using Amdocs.Ginger.Repository;` statement in Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs is necessary as it imports the ObservableList<> class which is used throughout the file.
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (1)

undefined

<retrieved_learning>
Learnt from: prashelke
PR: #4232
File: Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs:219-226
Timestamp: 2025-06-16T10:13:01.319Z
Learning: In VRTAnalyzer.cs for the GenericAppiumDriver class, the mAct.IsFullPageScreenshot flag is not applicable and should not be used to control screenshot behavior. GenericAppiumDriver always uses CaptureFullPageCroppedScreenshot() method regardless of the IsFullPageScreenshot flag setting.
</retrieved_learning>

🧬 Code Graph Analysis (1)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (2)
  • GenericAppiumDriver (83-5354)
  • GenericAppiumDriver (259-262)
🔇 Additional comments (1)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs (1)

219-230: Helper reduces duplication – good move

Replacing the two location-specific screenshot blocks with a single GetScreenshot() call tightens the logic and prevents drift between baseline and non-baseline paths.
No further issues spotted here.

Comment thread Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs Outdated
Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 16, 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

♻️ Duplicate comments (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (1)

1664-1717: Make full-page capture more robust & configurable

  1. maxScrolls is hard-coded to 10. Long pages on modern devices frequently exceed this. Expose it as an optional parameter or compute it from page height.
  2. Comment says “~5% for gesture bar” but you subtract 7 %. Align the comment or the calculation to avoid confusion.
  3. Duplicate detection still base-64 encodes every frame (heavy). A lightweight hash (MD5/SHA-1 over raw bytes) would cut CPU & memory.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9b9ff7a and db808f3.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (38 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (3)

undefined

<retrieved_learning>
Learnt from: prashelke
PR: #4232
File: Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/VRTAnalyzer.cs:219-226
Timestamp: 2025-06-16T10:13:01.319Z
Learning: In VRTAnalyzer.cs for the GenericAppiumDriver class, the mAct.IsFullPageScreenshot flag is not applicable and should not be used to control screenshot behavior. GenericAppiumDriver always uses CaptureFullPageCroppedScreenshot() method regardless of the IsFullPageScreenshot flag setting.
</retrieved_learning>

<retrieved_learning>
Learnt from: prashelke
PR: #4232
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs:1637-1655
Timestamp: 2025-06-16T12:22:07.984Z
Learning: The driver.ReleaseActions() method is deprecated in current versions of Appium and should not be used for managing action sequences.
</retrieved_learning>

<retrieved_learning>
Learnt from: prashelke
PR: #4232
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs:1637-1655
Timestamp: 2025-06-16T12:22:07.984Z
Learning: In Appium 2.x, driver.ReleaseActions() is deprecated. The current best practice is to use the W3C Actions API with fresh action sequences for each gesture, treating them as single-use objects. Action sequences should not be reused across multiple operations.
</retrieved_learning>

🧬 Code Graph Analysis (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (3)
Ginger/GingerCoreNET/ActionsLib/UI/Mobile/ActMobileDevice.cs (1)
  • ActMobileDevice (30-692)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (19)
  • Bitmap (2003-2035)
  • Bitmap (9544-9625)
  • Bitmap (9627-9660)
  • Bitmap (9701-9705)
  • Bitmap (9848-9876)
  • Bitmap (9877-9881)
  • Bitmap (9883-9964)
  • List (2296-2347)
  • List (4893-4968)
  • List (5207-5241)
  • List (6033-6054)
  • List (6124-6176)
  • List (8284-8296)
  • List (10157-10160)
  • List (10204-10223)
  • List (10297-10304)
  • List (10306-10367)
  • List (10712-10715)
  • List (10737-10740)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)

Comment on lines +1637 to +1662
private static void ScrollDown(AppiumDriver driver)
{
try
{
var windowSize = driver.Manage().Window.Size;

int startX = windowSize.Width / 2;
int startY = (int)(windowSize.Height * 0.8);
int endY = (int)(windowSize.Height * 0.2);

var touch = new PointerInputDevice(PointerKind.Touch);
var sequence = new ActionSequence(touch, 0);

sequence.AddAction(touch.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
sequence.AddAction(touch.CreatePointerDown(0));
sequence.AddAction(touch.CreatePause(TimeSpan.FromMilliseconds(300)));
sequence.AddAction(touch.CreatePointerMove(CoordinateOrigin.Viewport, startX, endY, TimeSpan.FromMilliseconds(500)));
sequence.AddAction(touch.CreatePointerUp(0));

driver.PerformActions(new List<ActionSequence> { sequence });
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred while scrolling for screen-shot", ex);
}
}

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.

🧹 Nitpick (assertive)

Use the same touch-action API everywhere

ScrollDown builds the gesture with OpenQA.Selenium.Interactions.PointerInputDevice, while the rest of the driver (e.g. TapXY, SwipeByXY) uses OpenQA.Selenium.Appium.Interactions.PointerInputDevice.
Mixing the two classes works today, but generates two different JSON payload formats and may break when the Appium client is upgraded. Stick to Appium.Interactions.PointerInputDevice for consistency across all gestures.

🤖 Prompt for AI Agents
In Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs
between lines 1637 and 1662, the ScrollDown method uses
OpenQA.Selenium.Interactions.PointerInputDevice instead of
OpenQA.Selenium.Appium.Interactions.PointerInputDevice like the rest of the
driver. To fix this, replace the usage of
OpenQA.Selenium.Interactions.PointerInputDevice with
OpenQA.Selenium.Appium.Interactions.PointerInputDevice in the ScrollDown method
to ensure consistent gesture building and avoid potential issues with different
JSON payload formats.

Comment on lines +1719 to +1747
private static Bitmap MergeScreenshotsVertically(List<Bitmap> images)
{
int totalHeight = images.Sum(img => img.Height);
int width = images[0].Width;

Bitmap finalImage = new Bitmap(width, totalHeight);
using (Graphics g = Graphics.FromImage(finalImage))
{
try
{
int offset = 0;
if (images == null || images.Count == 0)
{
throw new ArgumentException("images collection must contain at least one Bitmap", nameof(images));
}
foreach (var image in images)
{
g.DrawImage(image, new Rectangle(0, offset, image.Width, image.Height));
offset += image.Height;
image.Dispose(); // free as soon as we are done
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred while merging screen-shots", ex);
}
}
return finalImage;
}

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.

⚠️ Potential issue

Null / empty list guard is after the first access

MergeScreenshotsVertically dereferences images[0] before checking if the list is empty, so an empty collection raises ArgumentOutOfRangeException instead of your friendly ArgumentException.

-            int totalHeight = images.Sum(img => img.Height);
-            int width = images[0].Width;
-            if (images == null || images.Count == 0)
-                throw new ArgumentException("images collection must contain at least one Bitmap", nameof(images));
+            if (images == null || images.Count == 0)
+                throw new ArgumentException("images collection must contain at least one Bitmap", nameof(images));
+
+            int totalHeight = images.Sum(img => img.Height);
+            int width = images[0].Width;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private static Bitmap MergeScreenshotsVertically(List<Bitmap> images)
{
int totalHeight = images.Sum(img => img.Height);
int width = images[0].Width;
Bitmap finalImage = new Bitmap(width, totalHeight);
using (Graphics g = Graphics.FromImage(finalImage))
{
try
{
int offset = 0;
if (images == null || images.Count == 0)
{
throw new ArgumentException("images collection must contain at least one Bitmap", nameof(images));
}
foreach (var image in images)
{
g.DrawImage(image, new Rectangle(0, offset, image.Width, image.Height));
offset += image.Height;
image.Dispose(); // free as soon as we are done
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred while merging screen-shots", ex);
}
}
return finalImage;
}
private static Bitmap MergeScreenshotsVertically(List<Bitmap> images)
{
// guard against null or empty input before any dereferences
if (images == null || images.Count == 0)
throw new ArgumentException("images collection must contain at least one Bitmap", nameof(images));
int totalHeight = images.Sum(img => img.Height);
int width = images[0].Width;
Bitmap finalImage = new Bitmap(width, totalHeight);
using (Graphics g = Graphics.FromImage(finalImage))
{
try
{
int offset = 0;
foreach (var image in images)
{
g.DrawImage(image, new Rectangle(0, offset, image.Width, image.Height));
offset += image.Height;
image.Dispose(); // free as soon as we are done
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred while merging screen-shots", ex);
}
}
return finalImage;
}
🤖 Prompt for AI Agents
In Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs
around lines 1719 to 1747, the method MergeScreenshotsVertically accesses
images[0] before checking if the images list is null or empty, which can cause
an ArgumentOutOfRangeException. To fix this, move the null or empty check for
the images list to the very beginning of the method before any access to images
elements, and throw the ArgumentException if the list is null or empty. This
ensures the guard is effective and prevents invalid access.

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