[2d_drawing] Added existing addon in IN region.#311
[2d_drawing] Added existing addon in IN region.#311ManojTestsigma wants to merge 1 commit intodevfrom
Conversation
|
|
📝 WalkthroughWalkthroughIntroduces 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
There was a problem hiding this comment.
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: Addtestscope 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:
ServicesResourceTransformerto mergeMETA-INF/servicesfiles- 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-M1is 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 extendingDrawingActionfor consistency.
DrawLineOnElementandDrawPolygonOnElementextendDrawingAction, but this class extendsWebActiondirectly. This creates inconsistency and duplicates coordinate calculation logic (lines 43-50) that already exists inDrawingAction.getPointFromString().
58-66: AddRuntimeExceptionhandler for consistency with other drawing actions.
DrawLineOnElementandDrawPolygonOnElementhave a dedicatedRuntimeExceptioncatch block that usesruntimeErrorMessage. 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, andActionsare 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: Baseexecute()returningnullis risky.If
execute()is accidentally called on the base class (or a subclass forgets to override), returningnullcould causeNullPointerExceptionin calling code. Consider throwingUnsupportedOperationExceptionto 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"); |
There was a problem hiding this comment.
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.
| 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; |
There was a problem hiding this comment.
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.
| 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).
| 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"); | ||
| } |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
| 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(); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
| 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 | |||
There was a problem hiding this comment.
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:
- If this repository becomes public or is compromised, the key is exposed.
- Keys in version history are difficult to fully remove.
- 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.
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
✏️ Tip: You can customize this high-level summary in your review settings.