Skip to content

[2d_drawing] Added existing addon in IN region.#311

Open
ManojTestsigma wants to merge 1 commit intodevfrom
CUS-10283
Open

[2d_drawing] Added existing addon in IN region.#311
ManojTestsigma wants to merge 1 commit intodevfrom
CUS-10283

Conversation

@ManojTestsigma
Copy link
Copy Markdown
Contributor

@ManojTestsigma ManojTestsigma commented Jan 27, 2026

please review this addon and publish as PUBLIC

Addon name : 2d_drawing
Addon accont: https://jarvis-in.testsigma.com/ui/tenants/3/addons
Jira: https://testsigma.atlassian.net/browse/CUS-10283

fix

added existing addon to Indian region...

Summary by CodeRabbit

Release Notes

  • New Features
    • Draw lines on web elements with configurable start and end coordinates
    • Draw polygons on web elements using multiple coordinate points
    • Draw rectangles on web elements with customizable position and dimension parameters

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Introduces a new Maven module for 2D drawing capabilities, providing a base class for drawing actions and three concrete implementations (line, polygon, rectangle) that enable drawing shapes on web elements using relative percentage-based coordinates and Selenium WebDriver Actions API.

Changes

Cohort / File(s) Summary
Maven Configuration
2d_drawing/pom.xml
Defines project metadata (groupId: com.testsigma.addons, artifactId: 2d_drawing, version: 1.0.0, packaging: jar). Configures Java 11 compatibility, testsigma SDK, testing dependencies (JUnit, TestNG), Selenium/Appium clients, and Maven plugins (shade, source) for packaging and assembly.
Drawing Base Class
2d_drawing/src/main/java/com/testsigma/addons/web/DrawingAction.java
Base class extending WebAction providing utility methods: retrieveRelativePoints() for parsing relative coordinate strings, getPointFromString() for converting percentage-based offsets to absolute positions using element rectangle dimensions, and error handling infrastructure via runtimeErrorMessage field.
Drawing Action Implementations
2d_drawing/src/main/java/com/testsigma/addons/web/DrawLineOnElement.java, DrawPolygonOnElement.java, DrawRectangleOnElement.java
Three action classes for drawing shapes on elements. DrawLineOnElement draws a line between two points. DrawPolygonOnElement draws a closed polygon requiring at least three points. DrawRectangleOnElement draws a rectangle using start coordinates and dimensions. All parse relative coordinates, compute absolute positions, use Selenium Actions API, and include exception handling for boundary violations and runtime errors.
SDK Configuration
2d_drawing/src/main/resources/testsigma-sdk.properties
Resource properties file containing testsigma SDK API key for module authentication.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 With brush strokes drawn in code so fine,
Lines, polygons, rectangles align!
From percentage points to canvas clear,
Drawing actions bring shapes to cheer!
The addon hops with Selenium grace—hop hop

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding an existing 2d_drawing addon to the IN (India) region, which aligns with the file additions shown in the changeset.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

🤖 Fix all issues with AI agents
In `@2d_drawing/src/main/java/com/testsigma/addons/web/DrawLineOnElement.java`:
- Line 54: Fix the typo in the error message used in DrawLineOnElement by
changing the string passed to setErrorMessage from "The positions are not with
in the element" to "The positions are not within the element" (update the
setErrorMessage call in the DrawLineOnElement class).

In `@2d_drawing/src/main/java/com/testsigma/addons/web/DrawPolygonOnElement.java`:
- Line 50: The call actions.moveToLocation(point.x, point.y) is not part of
Selenium's Actions API; replace it with a supported method — e.g., if you have
the target element use actions.moveToElement(targetElement, point.x,
point.y).click().build().perform(); otherwise use actions.moveByOffset(point.x,
point.y).click().build().perform(); update the code in DrawPolygonOnElement to
use moveToElement(...) or moveByOffset(...) accordingly and ensure the correct
WebElement symbol (e.g., targetElement) is passed into moveToElement.
- Line 55: In DrawPolygonOnElement (class DrawPolygonOnElement) update the error
message string in the setErrorMessage call to correct the typo: replace "with
in" with "within" so the message reads "The positions are not within the
element"; locate the setErrorMessage(...) invocation and change only the string
literal.
- Around line 41-45: The validation in DrawPolygonOnElement currently uses
xyPairs.size() < 2 but should require at least 3 points; update the check to
xyPairs.size() < 3 in the method containing this block, adjust the
setRuntimeErrorMessage call if needed to remain consistent, and throw the
existing RuntimeException (or a more specific one) when the size is below 3 so
polygons with only two points are rejected; locate the condition and related
calls to setRuntimeErrorMessage and the RuntimeException in DrawPolygonOnElement
to make the change.
- Line 15: Replace the incorrect collection exception import in
DrawPolygonOnElement by removing the java.util.NoSuchElementException import and
importing Selenium's org.openqa.selenium.NoSuchElementException instead so the
class DrawPolygonOnElement uses the correct Selenium exception type consistent
with other drawing actions (update the import statement at the top of the file
to reference org.openqa.selenium.NoSuchElementException).

In
`@2d_drawing/src/main/java/com/testsigma/addons/web/DrawRectangleOnElement.java`:
- Line 54: The call to actions.moveToLocation(startX, startY) in
DrawRectangleOnElement uses a non-existent Selenium method; replace it with the
supported API by first moving to the target WebElement with
actions.moveToElement(targetElement, startX, startY) (or
actions.moveToElement(targetElement) then moveByOffset) and then perform
clickAndHold(), use moveByOffset(deltaX, deltaY) to reach endX/endY, then
release(). Update the invocation in the DrawRectangleOnElement class where
actions.moveToLocation is used and compute deltaX/deltaY as endX - startX if
using moveByOffset.
- Line 60: In DrawRectangleOnElement update the error message string passed to
setErrorMessage to correct the typo: replace "The positions are not with in the
element" with "The positions are not within the element" wherever
setErrorMessage(...) is called in that class/method to ensure consistent
wording.

In `@2d_drawing/src/main/resources/testsigma-sdk.properties`:
- Line 1: The file contains a hardcoded API key under the property
testsigma-sdk.api.key — remove the JWT value and replace it with a placeholder
that reads the key from an environment variable (e.g., reference
TESTSIGMA_SDK_API_KEY in your configuration loader where testsigma-sdk.api.key
is used), add this properties file to .gitignore so it is not committed, and
update deployment/config docs to instruct setting TESTSIGMA_SDK_API_KEY per
environment; also rotate/revoke the exposed key and purge it from the repo
history using your secret-removal process (git filter-repo/BFG) to ensure it is
no longer recoverable.
🧹 Nitpick comments (7)
2d_drawing/pom.xml (3)

42-46: Add test scope to TestNG dependency.

The TestNG dependency lacks a scope declaration, defaulting to compile. This will include TestNG in the shaded JAR unnecessarily. If it's only used for testing, add the test scope.

Suggested fix
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
             <version>6.14.3</version>
+            <scope>test</scope>
         </dependency>

74-86: Consider adding shade plugin configuration for dependency management.

The maven-shade-plugin has no transformers or relocations configured. For a library/addon, consider adding:

  • ServicesResourceTransformer to merge META-INF/services files
  • Package relocations if there's risk of classpath conflicts with consumer projects

This is optional if the addon runs in an isolated classloader.


17-17: Consider using a stable JUnit Jupiter release.

Version 5.8.0-M1 is a milestone (pre-release) version. For production code, use the latest stable release (5.14.1) instead.

2d_drawing/src/main/java/com/testsigma/addons/web/DrawRectangleOnElement.java (2)

22-22: Consider extending DrawingAction for consistency.

DrawLineOnElement and DrawPolygonOnElement extend DrawingAction, but this class extends WebAction directly. This creates inconsistency and duplicates coordinate calculation logic (lines 43-50) that already exists in DrawingAction.getPointFromString().


58-66: Add RuntimeException handler for consistency with other drawing actions.

DrawLineOnElement and DrawPolygonOnElement have a dedicated RuntimeException catch block that uses runtimeErrorMessage. This class lacks that handler, making error handling inconsistent.

Suggested fix
         } catch (MoveTargetOutOfBoundsException e) {
             logger.info("Invalid locations raised :" + ExceptionUtils.getStackTrace(e));
             setErrorMessage("The positions are not within the element");
             result = Result.FAILED;
+        } catch (RuntimeException e) {
+            logger.info("Exception occurred: " + ExceptionUtils.getStackTrace(e));
+            setErrorMessage("Runtime error occurred while drawing rectangle");
+            result = Result.FAILED;
         } catch (Exception e) {
             logger.info("Exception raised :" + ExceptionUtils.getStackTrace(e));
             setErrorMessage("Unable to generate the rectangle");
             result = Result.FAILED;
         }
2d_drawing/src/main/java/com/testsigma/addons/web/DrawingAction.java (2)

6-10: Remove unused imports.

By, StaleElementReferenceException, WebElement, and Actions are imported but not used in this class.

 import com.testsigma.sdk.Result;
 import com.testsigma.sdk.WebAction;
 import lombok.Data;
-import org.openqa.selenium.By;
 import org.openqa.selenium.NoSuchElementException;
-import org.openqa.selenium.StaleElementReferenceException;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;

22-25: Base execute() returning null is risky.

If execute() is accidentally called on the base class (or a subclass forgets to override), returning null could cause NullPointerException in calling code. Consider throwing UnsupportedOperationException to fail fast, or making the class/method abstract.

Suggested fix
     `@Override`
     protected Result execute() throws NoSuchElementException {
-        return null;
+        throw new UnsupportedOperationException("Subclasses must implement execute()");
     }

setSuccessMessage("Successfully drawn the line on the element");
} catch (MoveTargetOutOfBoundsException e) {
logger.info("Invalid locations raised :" + ExceptionUtils.getStackTrace(e));
setErrorMessage("The positions are not with in the element");
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

Fix typo: "with in" → "within".

-            setErrorMessage("The positions are not with in the element");
+            setErrorMessage("The positions are not within the element");
📝 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
setErrorMessage("The positions are not with in the element");
setErrorMessage("The positions are not within the element");
🤖 Prompt for AI Agents
In `@2d_drawing/src/main/java/com/testsigma/addons/web/DrawLineOnElement.java` at
line 54, Fix the typo in the error message used in DrawLineOnElement by changing
the string passed to setErrorMessage from "The positions are not with in the
element" to "The positions are not within the element" (update the
setErrorMessage call in the DrawLineOnElement class).


import java.awt.*;
import java.util.List;
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.

This imports java.util.NoSuchElementException (for collections), but Selenium uses org.openqa.selenium.NoSuchElementException. This inconsistency with other drawing actions may cause unexpected behavior or compilation issues depending on how the SDK handles exceptions.

-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
In `@2d_drawing/src/main/java/com/testsigma/addons/web/DrawPolygonOnElement.java`
at line 15, Replace the incorrect collection exception import in
DrawPolygonOnElement by removing the java.util.NoSuchElementException import and
importing Selenium's org.openqa.selenium.NoSuchElementException instead so the
class DrawPolygonOnElement uses the correct Selenium exception type consistent
with other drawing actions (update the import statement at the top of the file
to reference org.openqa.selenium.NoSuchElementException).

Comment on lines +41 to +45
if (xyPairs.size() < 2) {
setRuntimeErrorMessage(String.format("Provided positions are %s, minimum 3 positions are" +
" required to draw polygon", xyPairs.size()));
throw new RuntimeException("Invalid no of positions");
}
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

Logic bug: Check allows 2-point "polygons" despite requiring 3.

The condition xyPairs.size() < 2 allows 2 points, but the error message correctly states "minimum 3 positions are required to draw polygon". A polygon requires at least 3 vertices.

Proposed fix
-            if (xyPairs.size() < 2) {
+            if (xyPairs.size() < 3) {
                 setRuntimeErrorMessage(String.format("Provided positions are %s, minimum 3 positions are" +
                         " required to draw polygon", xyPairs.size()));
                 throw new RuntimeException("Invalid no of positions");
             }
🤖 Prompt for AI Agents
In `@2d_drawing/src/main/java/com/testsigma/addons/web/DrawPolygonOnElement.java`
around lines 41 - 45, The validation in DrawPolygonOnElement currently uses
xyPairs.size() < 2 but should require at least 3 points; update the check to
xyPairs.size() < 3 in the method containing this block, adjust the
setRuntimeErrorMessage call if needed to remain consistent, and throw the
existing RuntimeException (or a more specific one) when the size is below 3 so
polygons with only two points are rejected; locate the condition and related
calls to setRuntimeErrorMessage and the RuntimeException in DrawPolygonOnElement
to make the change.

xyPairs.add(xyPairs.get(0));
Actions actions = new Actions(driver);
for (Point point: xyPairs) {
actions.moveToLocation(point.x, point.y).click().build().perform();
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

Same moveToLocation concern as other drawing actions.

Verify moveToLocation(int, int) exists in Selenium Actions API.

🤖 Prompt for AI Agents
In `@2d_drawing/src/main/java/com/testsigma/addons/web/DrawPolygonOnElement.java`
at line 50, The call actions.moveToLocation(point.x, point.y) is not part of
Selenium's Actions API; replace it with a supported method — e.g., if you have
the target element use actions.moveToElement(targetElement, point.x,
point.y).click().build().perform(); otherwise use actions.moveByOffset(point.x,
point.y).click().build().perform(); update the code in DrawPolygonOnElement to
use moveToElement(...) or moveByOffset(...) accordingly and ensure the correct
WebElement symbol (e.g., targetElement) is passed into moveToElement.

setSuccessMessage("Successfully drawn the polygon using the given positions on the element");
} catch (MoveTargetOutOfBoundsException e) {
logger.info("Invalid locations raised :" + ExceptionUtils.getStackTrace(e));
setErrorMessage("The positions are not with in the element");
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

Fix typo: "with in" → "within".

-            setErrorMessage("The positions are not with in the element");
+            setErrorMessage("The positions are not within the element");
📝 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
setErrorMessage("The positions are not with in the element");
setErrorMessage("The positions are not within the element");
🤖 Prompt for AI Agents
In `@2d_drawing/src/main/java/com/testsigma/addons/web/DrawPolygonOnElement.java`
at line 55, In DrawPolygonOnElement (class DrawPolygonOnElement) update the
error message string in the setErrorMessage call to correct the typo: replace
"with in" with "within" so the message reads "The positions are not within the
element"; locate the setErrorMessage(...) invocation and change only the string
literal.

logger.info("Start locations relative to the given element startX - " + startX + ", startY - " + startY);

Actions actions = new Actions(driver);
actions.moveToLocation(startX, startY).clickAndHold().moveToLocation(endX, endY).release().build().perform();
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

Same moveToLocation concern as DrawLineOnElement.

Verify that moveToLocation(int, int) exists in the Selenium Actions API. The standard API uses moveToElement() or moveByOffset().

🤖 Prompt for AI Agents
In
`@2d_drawing/src/main/java/com/testsigma/addons/web/DrawRectangleOnElement.java`
at line 54, The call to actions.moveToLocation(startX, startY) in
DrawRectangleOnElement uses a non-existent Selenium method; replace it with the
supported API by first moving to the target WebElement with
actions.moveToElement(targetElement, startX, startY) (or
actions.moveToElement(targetElement) then moveByOffset) and then perform
clickAndHold(), use moveByOffset(deltaX, deltaY) to reach endX/endY, then
release(). Update the invocation in the DrawRectangleOnElement class where
actions.moveToLocation is used and compute deltaX/deltaY as endX - startX if
using moveByOffset.

" x: %s, y:%s", startX, startY));
} catch (MoveTargetOutOfBoundsException e) {
logger.info("Invalid locations raised :" + ExceptionUtils.getStackTrace(e));
setErrorMessage("The positions are not with in the element");
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

Fix typo: "with in" → "within".

-            setErrorMessage("The positions are not with in the element");
+            setErrorMessage("The positions are not within the element");
📝 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
setErrorMessage("The positions are not with in the element");
setErrorMessage("The positions are not within the element");
🤖 Prompt for AI Agents
In
`@2d_drawing/src/main/java/com/testsigma/addons/web/DrawRectangleOnElement.java`
at line 60, In DrawRectangleOnElement update the error message string passed to
setErrorMessage to correct the typo: replace "The positions are not with in the
element" with "The positions are not within the element" wherever
setErrorMessage(...) is called in that class/method to ensure consistent
wording.

@@ -0,0 +1 @@
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIzMmYwYTg1MC02NjMyLWIyN2ItOTBhYS1jZDkwMDcwNzRlMWUiLCJ1bmlxdWVJZCI6Ijc4IiwiaWRlbnRpdHlBY2NvdW50VVVJZCI6ImZlMmEzOGNiLThiODktNzdhNC04OTRiLTgwZjNiOWEzNzEzZSJ9.dlqB2YZsrCLNXozVRaubJ_ate5dx6JriR6DSaIgVAKwAdmJklmmSqbBFjohQyKlxNNRgTDWgQTIMbJa9_MXbBQ 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

Critical: Remove hardcoded API key from version control.

This file contains what appears to be a JWT token with sensitive identifiers (sub, uniqueId, identityAccountUUID). Committing secrets to version control is a security risk:

  1. If this repository becomes public or is compromised, the key is exposed.
  2. Keys in version history are difficult to fully remove.
  3. Different environments (dev/staging/prod) typically need different keys.

Use environment variables or a secrets management solution instead, and add this file to .gitignore.

🤖 Prompt for AI Agents
In `@2d_drawing/src/main/resources/testsigma-sdk.properties` at line 1, The file
contains a hardcoded API key under the property testsigma-sdk.api.key — remove
the JWT value and replace it with a placeholder that reads the key from an
environment variable (e.g., reference TESTSIGMA_SDK_API_KEY in your
configuration loader where testsigma-sdk.api.key is used), add this properties
file to .gitignore so it is not committed, and update deployment/config docs to
instruct setting TESTSIGMA_SDK_API_KEY per environment; also rotate/revoke the
exposed key and purge it from the repo history using your secret-removal process
(git filter-repo/BFG) to ensure it is no longer recoverable.

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