Skip to content

Conversation

@akhil-testsigma
Copy link
Contributor

@akhil-testsigma akhil-testsigma commented Oct 26, 2025

Publish this addon as public

Addon Name: Store Device Screen Dimensions
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-8160
Added Store Device Screen Dimensions addon for Android & iOS

Summary by CodeRabbit

  • New Features

    • Added device screen dimension capture actions for Android and iOS. Users can retrieve current device widthxheight and store it as a runtime variable for mobile test execution.
  • Chores

    • Included project build configuration and SDK configuration property to support packaging and runtime integration.

@coderabbitai
Copy link

coderabbitai bot commented Oct 26, 2025

Walkthrough

Adds a new add-on module that captures device screen dimensions on Android and iOS, stores them as "widthxheight" in a runtime variable, includes Maven build configuration, and adds an SDK properties file with an API key.

Changes

Cohort / File(s) Summary
Build Configuration
store_device_screen_dimensions/pom.xml
New Maven POM: packaging, Java 11, dependencies (testsigma-java-sdk, lombok, junit, testng, selenium, appium java-client, jackson, commons-lang3), maven-shade-plugin and maven-source-plugin configuration, finalName set.
Android Action
store_device_screen_dimensions/src/main/java/com/testsigma/addons/android/StoreDeviceScreenDimensions.java
New Android action class: retrieves AndroidDriver.manage().window().getSize(), formats as "{width}x{height}", stores into a runtime variable, sets success message, and handles exceptions (marks FAILED, logs stack trace).
iOS Action
store_device_screen_dimensions/src/main/java/com/testsigma/addons/ios/StoreDeviceScreenDimensions.java
New iOS action class: retrieves IOSDriver.manage().window().getSize(), formats as "{width}x{height}", stores into a runtime variable, sets success message, and handles exceptions (marks FAILED, logs stack trace).
SDK Configuration
store_device_screen_dimensions/src/main/resources/testsigma-sdk.properties
Added testsigma-sdk.api.key property with a JWT value.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as Test Runner
    participant Action as StoreDeviceScreenDimensions
    participant Driver as MobileDriver (Android/iOS)
    participant Runtime as RuntimeDataStore

    Runner->>Action: invoke execute(variableName)
    Action->>Driver: manage().window().getSize()
    Driver-->>Action: Size(width,height)
    Action->>Action: format "{width}x{height}"
    Action->>Runtime: set(variableName, formattedDimensions)
    Runtime-->>Action: ack
    Action-->>Runner: Result.SUCCESS (message)
    Note right of Action #DDEBF7: on exception -> set FAILED,\nrecord error + stack trace
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas that may need extra attention:
    • Correctness and safety of driver casts and null handling for driver and window size
    • Consistency of formatting and internationalization considerations
    • Secure handling of the API key in testsigma-sdk.properties (presence of long JWT)
    • Maven shade plugin configuration and dependency scopes

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 I hopped to peek at screens so wide,
I counted pixels side by side,
I stitched width, height with a gentle spin,
And tucked the size safe, tucked it in,
A tiny rabbit, storing stride.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "feat/CUS-8160-Added Store Device Screen Dimensions addon for Android & iOS" is fully related to the main change in the changeset. The title accurately describes what was added—a new addon for capturing device screen dimensions that works on both Android and iOS platforms. The title includes the issue reference (CUS-8160), is concise and specific, and a teammate scanning the history would clearly understand that this PR adds a new feature addon supporting both mobile platforms. The content matches the changeset which contains Android and iOS implementations of the StoreDeviceScreenDimensions class along with supporting build and configuration files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/CUS-8160-Added-Store-Device-Screen-Dimensions-addon-for-Android-&-iOS

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dee08a5 and a363c78.

📒 Files selected for processing (1)
  • store_device_screen_dimensions/src/main/java/com/testsigma/addons/ios/StoreDeviceScreenDimensions.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • store_device_screen_dimensions/src/main/java/com/testsigma/addons/ios/StoreDeviceScreenDimensions.java

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
store_device_screen_dimensions/src/main/java/com/testsigma/addons/android/StoreDeviceScreenDimensions.java (1)

32-56: LGTM: Solid implementation with good error handling.

The execute method correctly:

  • Retrieves window dimensions via AndroidDriver
  • Formats as "widthxheight"
  • Stores in runtime variable
  • Provides clear success/error messages
  • Catches and logs exceptions appropriately

Optional: Remove unnecessary NoSuchElementException declaration.

The method signature declares throws NoSuchElementException, but this exception is already a runtime exception and doesn't need explicit declaration. The catch block already handles all exceptions via catch (Exception e).

-public Result execute() throws NoSuchElementException {
+public Result execute() {

If you apply this change, also remove the unused import on line 5.

store_device_screen_dimensions/src/main/java/com/testsigma/addons/ios/StoreDeviceScreenDimensions.java (2)

15-54: Consider extracting common logic to reduce duplication.

The Android and iOS implementations are nearly identical (95%+ code duplication). The only differences are:

  • The driver type cast (AndroidDriver vs IOSDriver)
  • The base class (AndroidAction vs IOSAction)
  • The applicationType annotation

Consider creating a shared base class or utility method to eliminate duplication:

protected Result executeStoreScreenDimensions(WebDriver driver, String driverType) {
    logger.info("Starting to fetch " + driverType + " device screen dimensions...");
    Result result = Result.SUCCESS;
    
    try {
        Dimension size = driver.manage().window().getSize();
        logger.info("Size is: " + size.width + "x" + size.height);
        
        String dimensions = size.getWidth() + "x" + size.getHeight();
        runtimeData.setKey(variableName.getValue().toString());
        runtimeData.setValue(dimensions);
        
        setSuccessMessage("Successfully stored device dimensions '" + dimensions + 
            "' in runtime variable: " + runtimeData.getKey());
        logger.info("Device dimensions: " + dimensions);
        
    } catch (Exception e) {
        result = Result.FAILED;
        String errorMsg = "Failed to retrieve device dimensions: ";
        setErrorMessage(errorMsg + ExceptionUtils.getMessage(e));
        logger.warn(errorMsg + ExceptionUtils.getStackTrace(e));
    }
    
    return result;
}

Then each platform-specific class would simply call:

return executeStoreScreenDimensions(this.driver, "iOS"); // or "Android"

This improves maintainability and reduces the risk of copy-paste errors like the one on line 31.


30-30: Optional: Remove unnecessary exception declaration.

Same as the Android version - NoSuchElementException is a runtime exception and doesn't need explicit declaration.

-public Result execute() throws NoSuchElementException {
+public Result execute() {

If you apply this change, also remove the unused import on line 13.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1716e8b and dee08a5.

📒 Files selected for processing (4)
  • store_device_screen_dimensions/pom.xml (1 hunks)
  • store_device_screen_dimensions/src/main/java/com/testsigma/addons/android/StoreDeviceScreenDimensions.java (1 hunks)
  • store_device_screen_dimensions/src/main/java/com/testsigma/addons/ios/StoreDeviceScreenDimensions.java (1 hunks)
  • store_device_screen_dimensions/src/main/resources/testsigma-sdk.properties (1 hunks)
🔇 Additional comments (2)
store_device_screen_dimensions/src/main/java/com/testsigma/addons/android/StoreDeviceScreenDimensions.java (1)

17-22: LGTM: Clean action annotation and class structure.

The @Action annotation provides clear, descriptive text and specifies the correct application type for Android.

store_device_screen_dimensions/pom.xml (1)

59-63: I'll perform a web search to verify if there are any publicly reported security vulnerabilities for Jackson 2.13.0:

No critical security vulnerabilities found for jackson-annotations 2.13.0.

Jackson-databind versions before 2.13.0 were vulnerable to a denial of service via large depth of nested objects, but 2.13.0 itself addressed this. Jackson-annotations 2.13.0 had no changes since 2.12 and is a minimal annotations-only package with lower attack surface compared to jackson-databind. The GitHub Security Advisory search and web research found no published CVEs specific to jackson-annotations 2.13.0. This version is acceptable for use.

Comment on lines +42 to +46
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify TestNG version for security vulnerabilities.

TestNG 6.14.3 was released in 2018 and is significantly outdated. Older versions may contain security vulnerabilities or compatibility issues with newer Java versions.


🏁 Script executed:

#!/bin/bash
# Check for security advisories for TestNG version 6.14.3
gh api graphql -f query='
{
  securityVulnerabilities(first: 10, ecosystem: MAVEN, package: "org.testng:testng") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

Length of output: 469


Upgrade TestNG to 7.5.1 or later to address HIGH severity Path Traversal vulnerability.

TestNG 6.14.3 is vulnerable to a Path Traversal security issue (CVE severity: HIGH, published 2022-11-19). The vulnerability affects TestNG versions >= 6.13, < 7.5.1, with patches available in version 7.5.1. Update the dependency to version 7.5.1 or newer.

🤖 Prompt for AI Agents
In store_device_screen_dimensions/pom.xml around lines 42 to 46, the project
depends on TestNG 6.14.3 which is vulnerable; update the <version> for the
org.testng:testng dependency to 7.5.1 (or a later compatible 7.x) in the pom,
run a full build (mvn -U clean install) and re-run tests to ensure
compatibility, and if any test failures occur adjust test code or test-suite
XMLs to match TestNG 7.x behavior.

@@ -0,0 +1 @@
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjU1NDkiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiMzUifQ.qXL117SB2sZhSEDz9IQ7a9zZn3pz8RPdFh3EItAKtL5EYlgHMJZxOBdl3OWNy3sJrbI_E3gsWoaoRlXz5X8n9Q No newline at end of file
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

CRITICAL SECURITY ISSUE: Hardcoded API key in public repository.

This file contains a JWT token that will be exposed when the addon is published publicly. The token contains sensitive information including user identifiers (uniqueId: 5549, identityAccountUUId: 35). Hardcoded credentials in source code pose severe security risks:

  • Anyone with repository access can extract and misuse the API key
  • The token cannot be easily rotated without code changes
  • This violates security best practices and could lead to unauthorized access

Recommended solutions:

  1. Remove this file entirely and load the API key from environment variables:

    String apiKey = System.getenv("TESTSIGMA_SDK_API_KEY");
  2. Use a configuration management system that keeps credentials outside source control

  3. Document in README that users must provide their own API key via environment variable or secure configuration

  4. Immediately rotate this exposed token as it's now visible in the PR

🤖 Prompt for AI Agents
In store_device_screen_dimensions/src/main/resources/testsigma-sdk.properties
around line 1 there is a hardcoded JWT API key which must be removed
immediately; delete the file or remove the secret value from source, replace
usage with loading the API key from a secure source such as an environment
variable (e.g. TESTSIGMA_SDK_API_KEY) or a secrets/config management system, add
the properties file to .gitignore if needed and update code/config to fail fast
with a clear error when the env var is missing, update the README with
instructions for providing the API key, and ensure the exposed token is rotated
immediately outside this PR.

@akhil-testsigma akhil-testsigma merged commit ae8558d into dev Oct 27, 2025
2 checks passed
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.

3 participants