Skip to content

feat/CUS-10727-Added class to swipe based on directions#338

Merged
akhil-testsigma merged 2 commits into
devfrom
feat/CUS-10727-Added-class-to-swipe-based-on-directions
Feb 17, 2026
Merged

feat/CUS-10727-Added class to swipe based on directions#338
akhil-testsigma merged 2 commits into
devfrom
feat/CUS-10727-Added-class-to-swipe-based-on-directions

Conversation

@akhil-testsigma
Copy link
Copy Markdown
Contributor

@akhil-testsigma akhil-testsigma commented Feb 17, 2026

Publish this addon as PUBLIC

Addon Name: Swipe Inside Element With Direction
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-10727
Added class to swipe based on directions

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a new directional swipe action for web elements, enabling users to swipe in specified directions (e.g., left, right, up, down) within target elements during test execution.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new Maven addon project for TestSigma that provides a WebAction to perform swipe gestures within a specified element. The project includes Maven configuration, the SwipeWithInElementOffset action implementation supporting directional swipes, and SDK configuration properties.

Changes

Cohort / File(s) Summary
Maven Project Configuration
swipe_within_element_with_offset/pom.xml
Defines project coordinates, dependencies (testsigma-java-sdk, Selenium, JUnit, TestNG, Jackson), and build plugins (maven-shade-plugin for packaging, maven-source-plugin for source attachment).
WebAction Implementation
swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java
Introduces SwipeWithInElementOffset action supporting directional swipes (e.g., TOP TO BOTTOM) within an element. Includes direction parsing, point calculation with 10-pixel inset boundaries, Selenium Actions-based swipe execution, and error handling for element location and direction validation.
SDK Configuration
swipe_within_element_with_offset/src/main/resources/testsigma-sdk.properties
Adds SDK API key property for authentication with TestSigma backend services.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 Whiskers twitch with glee, a swipe so fine,
Within the element, directions align,
From top to bottom, the gesture takes flight,
A hop, a swish, precision just right!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: introducing a new class (SwipeWithInElementOffset) that enables swiping within elements based on directional input.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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-10727-Added-class-to-swipe-based-on-directions

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
Copy Markdown

@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)
swipe_within_element_with_offset/pom.xml (1)

17-17: JUnit Jupiter 5.8.0-M1 is a pre-release milestone version.

Consider using a stable GA release (e.g., 5.10.x or 5.11.x) for more reliable test infrastructure.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@swipe_within_element_with_offset/pom.xml` at line 17, The pom defines a
pre-release JUnit version via the property junit.jupiter.version; update that
property value from 5.8.0-M1 to a stable GA release (for example 5.10.0 or
5.11.0) in the pom.xml so the build uses a supported JUnit Jupiter release, then
re-run your build/tests to verify compatibility; look for the
junit.jupiter.version property to make this change.
swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java (2)

84-106: Hardcoded 10px inset may cause issues for small elements.

If the element is smaller than 20px in either dimension, the inset of 10 can push computed points outside the element bounds or collapse the swipe distance to zero. Consider clamping the inset to a fraction of the element's dimensions.

Suggested defensive guard
         int inset = 10;
+        inset = Math.min(inset, elementWidth / 4);
+        inset = Math.min(inset, elementHeight / 4);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java`
around lines 84 - 106, The hardcoded inset=10 in getPointInElement can push
points outside small elements; change inset to a defensive value based on the
element size (for example compute inset = Math.max(1, Math.min(10,
Math.min(elementWidth, elementHeight) / 4))) and then ensure the returned x/y
are clamped inside the element bounds (between location.getX() and
location.getX()+elementWidth-1, and similarly for Y) so
TOP/MIDDLE/BOTTOM/LEFT/RIGHT computations never produce coordinates outside the
element.

69-77: Use appropriate log levels for error conditions.

Lines 70 and 75 use logger.info for exception/error scenarios. These should use logger.warn or logger.error to correctly reflect severity and make log filtering meaningful.

Proposed fix
         } catch (NoSuchElementException e) {
-            logger.info("Element not found: " + e.getMessage());
+            logger.error("Element not found: " + e.getMessage());
             setErrorMessage("Element not found: " + e.getMessage());
             result = Result.FAILED;
 
         } catch (Exception e) {
-            logger.info("Error occurred: " + e.getMessage());
+            logger.error("Error occurred: " + e.getMessage());
             setErrorMessage("Error: " + e.getMessage());
             result = Result.FAILED;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java`
around lines 69 - 77, Change the logger calls in the exception handlers to use
appropriate severity: replace logger.info in the NoSuchElementException catch
with logger.warn and replace logger.info in the generic Exception catch with
logger.error; update the log calls around the catch blocks that reference
NoSuchElementException, Exception, setErrorMessage, result, and Result.FAILED so
the warnings/errors correctly reflect severity (and keep existing
setErrorMessage(...) and result = Result.FAILED behavior).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@swipe_within_element_with_offset/pom.xml`:
- Around line 42-46: The TestNG dependency block (artifactId "testng") currently
lacks a test scope and will be included in the shaded production JAR; update the
dependency definition for artifactId "testng" (version 6.14.3) to include
<scope>test</scope> so TestNG and its transitive dependencies are only used at
test time and not packaged into the production/shaded artifact.

In
`@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java`:
- Line 13: The import is wrong: replace java.util.NoSuchElementException with
org.openqa.selenium.NoSuchElementException so the catch in the
SwipeWithInElementOffset class (the try/catch around element lookup / actions
that currently intends to handle Selenium's missing-element case) actually
catches Selenium's exception and returns Result.FAILED; remove the java.util
import if present and ensure the catch clause references
org.openqa.selenium.NoSuchElementException (or a plain NoSuchElementException
after fixing the import).

In
`@swipe_within_element_with_offset/src/main/resources/testsigma-sdk.properties`:
- Line 1: The committed secret JWT in the property testsigma-sdk.api.key must be
removed and rotated: revoke the exposed key immediately, purge it from git
history (e.g., BFG or git filter-repo) so it no longer exists in any commit, and
replace the hardcoded value in testsigma-sdk.properties with a placeholder that
reads the key from an environment variable (e.g., reference TESTSIGMA_API_KEY)
or a file ignored by git; also add the properties file or its containing pattern
to .gitignore and update CI/secret manager to provide the new key.

---

Nitpick comments:
In `@swipe_within_element_with_offset/pom.xml`:
- Line 17: The pom defines a pre-release JUnit version via the property
junit.jupiter.version; update that property value from 5.8.0-M1 to a stable GA
release (for example 5.10.0 or 5.11.0) in the pom.xml so the build uses a
supported JUnit Jupiter release, then re-run your build/tests to verify
compatibility; look for the junit.jupiter.version property to make this change.

In
`@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java`:
- Around line 84-106: The hardcoded inset=10 in getPointInElement can push
points outside small elements; change inset to a defensive value based on the
element size (for example compute inset = Math.max(1, Math.min(10,
Math.min(elementWidth, elementHeight) / 4))) and then ensure the returned x/y
are clamped inside the element bounds (between location.getX() and
location.getX()+elementWidth-1, and similarly for Y) so
TOP/MIDDLE/BOTTOM/LEFT/RIGHT computations never produce coordinates outside the
element.
- Around line 69-77: Change the logger calls in the exception handlers to use
appropriate severity: replace logger.info in the NoSuchElementException catch
with logger.warn and replace logger.info in the generic Exception catch with
logger.error; update the log calls around the catch blocks that reference
NoSuchElementException, Exception, setErrorMessage, result, and Result.FAILED so
the warnings/errors correctly reflect severity (and keep existing
setErrorMessage(...) and result = Result.FAILED behavior).

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

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

TestNG dependency is missing <scope>test</scope> — it will be shaded into the production jar.

Without the test scope, TestNG (and its transitive dependencies) will be bundled into the shaded jar, bloating it unnecessarily.

Proposed fix
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
             <version>6.14.3</version>
+            <scope>test</scope>
         </dependency>
📝 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
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@swipe_within_element_with_offset/pom.xml` around lines 42 - 46, The TestNG
dependency block (artifactId "testng") currently lacks a test scope and will be
included in the shaded production JAR; update the dependency definition for
artifactId "testng" (version 6.14.3) to include <scope>test</scope> so TestNG
and its transitive dependencies are only used at test time and not packaged into
the production/shaded artifact.

import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import java.util.NoSuchElementException;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Wrong NoSuchElementException imported — Selenium's element-not-found exceptions will not be caught.

java.util.NoSuchElementException is thrown by iterators/enumerations, not by Selenium. When an element is not found, Selenium throws org.openqa.selenium.NoSuchElementException. The catch block on line 69 will never catch the actual Selenium exception, causing it to propagate uncaught instead of returning Result.FAILED.

Proposed fix
-import java.util.NoSuchElementException;
+import org.openqa.selenium.NoSuchElementException;
📝 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
import java.util.NoSuchElementException;
import org.openqa.selenium.NoSuchElementException;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java`
at line 13, The import is wrong: replace java.util.NoSuchElementException with
org.openqa.selenium.NoSuchElementException so the catch in the
SwipeWithInElementOffset class (the try/catch around element lookup / actions
that currently intends to handle Selenium's missing-element case) actually
catches Selenium's exception and returns Result.FAILED; remove the java.util
import if present and ensure the catch clause references
org.openqa.selenium.NoSuchElementException (or a plain NoSuchElementException
after fixing the import).

@@ -0,0 +1 @@
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxM2M5YWYzOS0zMWIwLWM2NDUtMjdhMS0xNDVhMTRjMmFkMTUiLCJ1bmlxdWVJZCI6IjU5NjMiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiYWUwYzE3MDMtNzM4MC1kMjkzLTRiYjQtZDU3Y2ZmNzc1MWM0In0.Y8datKRXZHInIHWmDm9M9rWCZ7HSdRuIxKxW-MkTztarRV_6EFMqYO4yesYW0CGqQZ-HNYiWPvIRmWiVOEGfoA No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🚨 Secret API key committed to a public repository.

This file contains a hardcoded JWT API key that will be pushed to a public GitHub repository. The JWT payload includes identifiable account information (sub, uniqueId, identityAccountUUId). This key must be:

  1. Revoked immediately — assume it is compromised once pushed.
  2. Removed from Git history (e.g., via git filter-branch or BFG Repo-Cleaner), since deleting the file in a subsequent commit does not remove it from history.
  3. Replaced with an environment variable, CI secret, or a .properties file listed in .gitignore.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@swipe_within_element_with_offset/src/main/resources/testsigma-sdk.properties`
at line 1, The committed secret JWT in the property testsigma-sdk.api.key must
be removed and rotated: revoke the exposed key immediately, purge it from git
history (e.g., BFG or git filter-repo) so it no longer exists in any commit, and
replace the hardcoded value in testsigma-sdk.properties with a placeholder that
reads the key from an environment variable (e.g., reference TESTSIGMA_API_KEY)
or a file ignored by git; also add the properties file or its containing pattern
to .gitignore and update CI/secret manager to provide the new key.

Copy link
Copy Markdown

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

🧹 Nitpick comments (1)
swipe_inside_element_with_direction/pom.xml (1)

42-46: TestNG dependency missing <scope>test</scope>.

This will be included in the shaded JAR via maven-shade-plugin, bloating the artifact. If it's only used for tests, add test scope.

Proposed fix
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
             <version>6.14.3</version>
+            <scope>test</scope>
         </dependency>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@swipe_inside_element_with_direction/pom.xml` around lines 42 - 46, The TestNG
dependency (groupId org.testng, artifactId testng, version 6.14.3) lacks a test
scope and is therefore pulled into the shaded JAR; update the dependency
declaration for org.testng:testng:6.14.3 to include <scope>test</scope> so Maven
treats it as a test-only dependency and the maven-shade-plugin will not package
it into the final artifact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@swipe_inside_element_with_direction/src/main/java/com/testsigma/addons/web/SwipeWithInElement.java`:
- Line 13: The import of java.util.NoSuchElementException is incorrect for
Selenium handling; update the import to
org.openqa.selenium.NoSuchElementException (and remove the java.util import) so
the catch in SwipeWithInElement that currently intends to handle
element-not-found exceptions will actually catch Selenium's exception type;
ensure any catch blocks referencing NoSuchElementException (in methods like the
swipe/execute logic) remain unchanged so they now reference the Selenium
exception class.

---

Nitpick comments:
In `@swipe_inside_element_with_direction/pom.xml`:
- Around line 42-46: The TestNG dependency (groupId org.testng, artifactId
testng, version 6.14.3) lacks a test scope and is therefore pulled into the
shaded JAR; update the dependency declaration for org.testng:testng:6.14.3 to
include <scope>test</scope> so Maven treats it as a test-only dependency and the
maven-shade-plugin will not package it into the final artifact.

import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import java.util.NoSuchElementException;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Wrong NoSuchElementException import — Selenium's exception will never be caught by the dedicated handler.

java.util.NoSuchElementException is not the same as org.openqa.selenium.NoSuchElementException. The catch block on line 69 targets the java.util variant, so Selenium's "element not found" exception will bypass it and fall into the generic Exception catch instead, losing the specific error message.

Proposed fix
-import java.util.NoSuchElementException;
+import org.openqa.selenium.NoSuchElementException;
📝 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
import java.util.NoSuchElementException;
import org.openqa.selenium.NoSuchElementException;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@swipe_inside_element_with_direction/src/main/java/com/testsigma/addons/web/SwipeWithInElement.java`
at line 13, The import of java.util.NoSuchElementException is incorrect for
Selenium handling; update the import to
org.openqa.selenium.NoSuchElementException (and remove the java.util import) so
the catch in SwipeWithInElement that currently intends to handle
element-not-found exceptions will actually catch Selenium's exception type;
ensure any catch blocks referencing NoSuchElementException (in methods like the
swipe/execute logic) remain unchanged so they now reference the Selenium
exception class.

@akhil-testsigma akhil-testsigma merged commit 3aee8fc into dev Feb 17, 2026
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.

2 participants