Skip to content

Conversation

@akhil-testsigma
Copy link
Contributor

@akhil-testsigma akhil-testsigma commented Nov 6, 2025

Publish this addon as public

Addon Name: Tap And Hold On Element For Duration
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-8510
Added support for tap and hold on element for duration on Android elements

Summary by CodeRabbit

  • New Features
    • Added a tap-and-hold gesture action that allows holding an element for a specified duration
    • Includes validation for hold duration and element visibility checks
    • Provides detailed error handling and logging for better test execution visibility

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

This pull request introduces a new Maven module implementing an Android action addon for Testsigma that enables tap-and-hold gesture functionality on mobile elements with configurable duration. The module includes Maven configuration, an action implementation class, and SDK properties setup.

Changes

Cohort / File(s) Summary
Maven Configuration
tap_and_hold_on_element_for_duration/pom.xml
Defines project structure with Java 11 compatibility, declares dependencies for Testsigma SDK, testing frameworks (JUnit, TestNG), Selenium, Android client, and Jackson; configures maven-shade-plugin for shaded JAR packaging and maven-source-plugin for source attachment.
Android Action Implementation
tap_and_hold_on_element_for_duration/src/main/java/com/testsigma/addons/android/TapAndHoldOnElementForDuration.java
Implements tap-and-hold gesture action extending AndroidAction; validates non-negative hold duration, retrieves and checks element visibility, executes Appium TouchAction long press for specified duration, with comprehensive error handling and user-facing success/error messages.
SDK Configuration
tap_and_hold_on_element_for_duration/src/main/resources/testsigma-sdk.properties
Adds SDK configuration file with API key property for Testsigma authentication.

Sequence Diagram

sequenceDiagram
    participant Test as Test Framework
    participant Action as TapAndHoldOnElementForDuration
    participant Driver as AndroidDriver
    participant Element as WebElement

    Test->>Action: execute()
    activate Action
    
    rect rgb(200, 220, 255)
    Note over Action: Validate Duration
    alt Duration < 0
        Action-->>Test: FAILED (Invalid duration)
    end
    end
    
    rect rgb(220, 200, 255)
    Note over Action: Get & Check Element
    Action->>Driver: findElement()
    Driver-->>Element: WebElement
    alt Element not visible
        Action-->>Test: FAILED (Element not visible)
    end
    end
    
    rect rgb(200, 255, 220)
    Note over Action: Perform Gesture
    Action->>Driver: new TouchAction(driver)
    Driver->>Element: longPress(duration)
    Driver->>Driver: release().perform()
    end
    
    Action->>Action: Log Success
    Action-->>Test: SUCCESS
    deactivate Action
Loading

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Key areas requiring attention:
    • TouchAction implementation and Appium duration handling correctness
    • Visibility validation logic and WebElement retrieval
    • Error message clarity and logging completeness
    • Annotation usage alignment with Testsigma SDK patterns (@Element and @TestData references)

Suggested Reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 A tap and hold, so gentle and true,
On Android screens, this addon shines through,
With configurable seconds, the gesture takes flight,
Touch, press, and release—mobile testing's delight! ✨

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 title accurately describes the main change: adding support for tap-and-hold functionality on Android elements, which is the primary feature introduced across all modified/added 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-8510-Added-support-for-tap-and-hold-on-element-for-duration-on-Android-elements

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 (2)
tap_and_hold_on_element_for_duration/pom.xml (1)

42-46: Update TestNG to a recent version.

TestNG 6.14.3 is from 2018 and is significantly outdated. Consider upgrading to version 7.x for bug fixes, security patches, and compatibility improvements.

         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
-            <version>6.14.3</version>
+            <version>7.10.2</version>
         </dependency>
tap_and_hold_on_element_for_duration/src/main/java/com/testsigma/addons/android/TapAndHoldOnElementForDuration.java (1)

51-69: Add explicit wait for element visibility.

The direct isDisplayed() check without an explicit wait can lead to flaky test execution. If the element is still rendering, the check might fail prematurely.

+            WebDriverWait wait = new WebDriverWait(androidDriver, Duration.ofSeconds(10));
+            try {
+                wait.until(ExpectedConditions.visibilityOf(webElement));
+            } catch (TimeoutException e) {
+                result = com.testsigma.sdk.Result.FAILED;
+                logger.warn("Element is not visible within timeout");
+                setErrorMessage("Element is not visible within timeout");
+                return result;
+            }
+
-            if (webElement.isDisplayed()) {
                 logger.info("Element is visible, performing long press for " + holdSeconds + " seconds...");
                 // ... rest of the code
-            } else {
-                result = com.testsigma.sdk.Result.FAILED;
-                logger.warn("Element is not visible");
-                setErrorMessage("Element is not visible");
-                return result;
-            }

Note: Add imports:

import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.TimeoutException;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b8eb04 and 3d92ace.

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

42-47: Good validation, but consider zero as valid.

The validation correctly rejects negative durations. However, consider whether a zero-second hold duration is a valid use case (immediate tap-release). If so, the condition should be holdSeconds < 0 (which is already correct). If not, it should be holdSeconds <= 0.


60-63: LGTM: Clear and informative success message.

The success message provides all relevant details including duration, locator type, and locator value, which is helpful for debugging and test reporting.

tap_and_hold_on_element_for_duration/pom.xml (2)

59-63: jackson-annotations 2.13.0 is current stable and no known security vulnerabilities found for this package.

Version 2.13.0 is part of Jackson's current stable, actively maintained branch. The 2.13 release notes indicate "No changes since 2.12", and this version was released on September 30, 2021. The GitHub Security Advisory search returned no known CVEs for jackson-annotations 2.13.0 (distinct from jackson-databind vulnerabilities). For consistency with newer releases, Jackson 2.20 was released on August 28, 2025, though updating to a newer minor version is optional rather than critical.


48-58: Update dependency versions to latest stable releases.

Selenium-java 4.33.0 is outdated; the latest stable version is 4.38.0 (released Oct 25, 2025). Appium java-client 9.4.0 should be updated to 10.0.0 (released Aug 13, 2025). Verify that the Appium major version upgrade introduces no breaking changes in your codebase before updating.

Comment on lines +8 to +11
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.touch.WaitOptions;
import io.appium.java_client.touch.offset.ElementOption;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Critical: TouchAction API is deprecated.

The TouchAction class and related APIs (WaitOptions, ElementOption) are deprecated in Appium's java-client. Modern Appium uses W3C Actions API or mobile-specific gesture commands.

Consider using one of these modern approaches:

Option 1: W3C Actions API (preferred)

import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.Pause;
import org.openqa.selenium.interactions.PointerInput;
import org.openqa.selenium.interactions.Sequence;

// In execute method:
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence longPress = new Sequence(finger, 1)
    .addAction(finger.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), 
               webElement.getLocation().getX(), webElement.getLocation().getY()))
    .addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()))
    .addAction(new Pause(finger, Duration.ofSeconds(holdSeconds)))
    .addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));

androidDriver.perform(List.of(longPress));

Option 2: Mobile gesture command

androidDriver.executeScript("mobile: longClickGesture", Map.of(
    "elementId", ((RemoteWebElement) webElement).getId(),
    "duration", holdSeconds * 1000
));
🤖 Prompt for AI Agents
In
tap_and_hold_on_element_for_duration/src/main/java/com/testsigma/addons/android/TapAndHoldOnElementForDuration.java
around lines 8 to 11, the code imports and uses deprecated
TouchAction/WaitOptions/ElementOption APIs; replace this with a modern W3C
Actions or mobile gesture implementation. Preferred: use Selenium W3C
PointerInput/Sequence to perform a touch pointer move to the element center,
pointerDown, a Pause for the required duration, then pointerUp and call
androidDriver.perform with the sequence; ensure you compute element coordinates
(center) and convert duration to a java.time.Duration. Alternate: use the mobile
gesture command via androidDriver.executeScript("mobile: longClickGesture",
Map.of("elementId", ((RemoteWebElement)element).getId(), "duration",
holdSeconds*1000)) if you prefer a simpler platform-specific approach. Ensure to
remove deprecated imports and add required imports for PointerInput, Sequence,
Pause and Duration.

WebElement webElement = element.getElement();

try {
int holdSeconds = Integer.parseInt(timeInSeconds.getValue().toString());
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add explicit handling for invalid numeric input.

Integer.parseInt() will throw NumberFormatException if the input is not a valid integer. While this is caught by the generic exception handler, providing a specific error message would improve user experience.

+        try {
             int holdSeconds = Integer.parseInt(timeInSeconds.getValue().toString());
+        } catch (NumberFormatException e) {
+            logger.warn("Invalid time format: " + timeInSeconds.getValue());
+            setErrorMessage("Time parameter must be a valid integer, received: " + timeInSeconds.getValue());
+            return com.testsigma.sdk.Result.FAILED;
+        }
📝 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
int holdSeconds = Integer.parseInt(timeInSeconds.getValue().toString());
try {
int holdSeconds = Integer.parseInt(timeInSeconds.getValue().toString());
} catch (NumberFormatException e) {
logger.warn("Invalid time format: " + timeInSeconds.getValue());
setErrorMessage("Time parameter must be a valid integer, received: " + timeInSeconds.getValue());
return com.testsigma.sdk.Result.FAILED;
}
🤖 Prompt for AI Agents
In
tap_and_hold_on_element_for_duration/src/main/java/com/testsigma/addons/android/TapAndHoldOnElementForDuration.java
around line 40, Integer.parseInt(timeInSeconds.getValue().toString()) can throw
NumberFormatException for invalid input; wrap the parse in a try/catch that
catches NumberFormatException (after trimming the string), and in the catch
log/throw a clear, user-facing error that includes the invalid value and states
an integer number of seconds is expected (or set a validated default/exit flow
as appropriate) so the error is explicit rather than buried in a generic
exception handler.

@@ -0,0 +1 @@
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjU2MTYiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiMzUifQ.xMWTzBwe5zvZWgizb9c0wOhdMRMWJ5J2mo9hVPfsXezVQ3HfNixUaRstWCbenKuq2E6WrCHPjS0u2qTidNsERA 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: Remove hardcoded API key from version control.

This file contains a hardcoded JWT token that appears to be a sensitive API key. Credentials should never be committed to version control as they can be exposed to anyone with repository access.

Recommended approach:

  • Remove this file from the repository and add it to .gitignore
  • Use environment variables or a secure secrets management system
  • Provide a template file (e.g., testsigma-sdk.properties.template) with placeholder values
  • Rotate the exposed API key immediately as it may already be compromised
#!/bin/bash
# Verify if there's a .gitignore that excludes properties files with secrets
rg -n "testsigma-sdk\.properties" .gitignore || echo "No .gitignore entry found for testsigma-sdk.properties"

# Check if similar patterns exist in other modules
fd -e properties . --exec grep -l "api.key"
🤖 Prompt for AI Agents
In
tap_and_hold_on_element_for_duration/src/main/resources/testsigma-sdk.properties
lines 1-1: this file contains a hardcoded sensitive API/JWT token; remove the
credential from version control immediately by deleting the file from the repo
(or removing the secret line and committing), add testsigma-sdk.properties to
.gitignore, create a testsigma-sdk.properties.template with placeholder keys,
switch the code to read the API key from an environment variable or a secret
manager instead of this file, and rotate/revoke the exposed API key as it may be
compromised.

@akhil-testsigma akhil-testsigma merged commit dc960d0 into dev Nov 7, 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