feat/CUS-11086-Added class to clear the input field using backspace#353
Conversation
📝 WalkthroughWalkthroughA new Maven Java project is introduced that provides custom Testsigma action classes for clearing input fields using backspace keystrokes. The project includes separate implementations for web and mobile web environments, along with standard build configuration and dependencies on Selenium, TestNG, and Testsigma SDK. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 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
🧪 Generate unit tests (beta)
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: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@clear_input_field_using_backspace/src/main/java/com/testsigma/addons/web/ClearUsingBackspace.java`:
- Around line 53-54: The code in ClearUsingBackspace currently prints the full
stack trace and raw exception message; replace those with non-sensitive,
user-friendly messages: change logger.warn("Failed to clear the input field: " +
ExceptionUtils.getStackTrace(e)) to a generic warn like logger.warn("Failed to
clear the input field") and, if you need the exception for debugging, log the
stacktrace at debug level (e.g., logger.debug("clear failure", e)). Replace
setErrorMessage("Failed to clear the input field due to: " +
ExceptionUtils.getMessage(e)) with a generic user-facing message such as
setErrorMessage("Failed to clear the input field.") and optionally include a
short, non-sensitive error code or e.getClass().getSimpleName() if you need
minimal diagnostic info.
- Around line 48-50: The code in ClearUsingBackspace sets result to SUCCESS
(using logger, setSuccessMessage, and result) without verifying the field was
actually cleared; modify the clear routine in the ClearUsingBackspace class to
read the field value after sending backspaces (e.g., via
element.getAttribute("value") or element.getText()), perform a short retry loop
with a few small waits to allow JS to update, and only set result =
com.testsigma.sdk.Result.SUCCESS and call setSuccessMessage(...) if the
post-condition shows an empty value; otherwise set an appropriate failure
result/message.
In
`@clear_input_field_using_backspace/src/main/resources/testsigma-sdk.properties`:
- Line 1: The committed file contains a plaintext SDK API key under the property
testsigma-sdk.api.key; remove this secret from the repository immediately,
rotate the exposed key in the provider, purge it from git history (e.g., git
filter-repo or BFG), and replace the hardcoded entry with a secure runtime
lookup (e.g., read testsigma API key from an environment variable or injected
secret manager value and reference that variable name where
testsigma-sdk.api.key was used). Ensure any code that referenced
testsigma-sdk.api.key is updated to read from the new secure source and add the
property name (or env var) to the project's .gitignore and secrets documentation
so future commits do not reintroduce secrets.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bfc94b11-e853-4321-aebb-896764ae437f
📒 Files selected for processing (4)
clear_input_field_using_backspace/pom.xmlclear_input_field_using_backspace/src/main/java/com/testsigma/addons/mobileweb/ClearUsingBackspace.javaclear_input_field_using_backspace/src/main/java/com/testsigma/addons/web/ClearUsingBackspace.javaclear_input_field_using_backspace/src/main/resources/testsigma-sdk.properties
| logger.info("Successfully cleared the input field using backspace"); | ||
| setSuccessMessage("Successfully cleared the input field using backspace"); | ||
| result = com.testsigma.sdk.Result.SUCCESS; |
There was a problem hiding this comment.
Verify the field is actually empty before returning SUCCESS.
Line 48-Line 50 marks success without validating the clear operation outcome. If key events are ignored/intercepted, this can return a false positive.
✅ Proposed post-condition check
if (text != null) {
for (int i = 0; i < text.length(); i++) {
webElement.sendKeys(Keys.BACK_SPACE);
}
}
+
+ String remaining = webElement.getAttribute("value");
+ if (remaining != null && !remaining.isEmpty()) {
+ setErrorMessage("Unable to clear the input field completely.");
+ return com.testsigma.sdk.Result.FAILED;
+ }
logger.info("Successfully cleared the input field using backspace");
setSuccessMessage("Successfully cleared the input field using backspace");
result = com.testsigma.sdk.Result.SUCCESS;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@clear_input_field_using_backspace/src/main/java/com/testsigma/addons/web/ClearUsingBackspace.java`
around lines 48 - 50, The code in ClearUsingBackspace sets result to SUCCESS
(using logger, setSuccessMessage, and result) without verifying the field was
actually cleared; modify the clear routine in the ClearUsingBackspace class to
read the field value after sending backspaces (e.g., via
element.getAttribute("value") or element.getText()), perform a short retry loop
with a few small waits to allow JS to update, and only set result =
com.testsigma.sdk.Result.SUCCESS and call setSuccessMessage(...) if the
post-condition shows an empty value; otherwise set an appropriate failure
result/message.
| logger.warn("Failed to clear the input field: " + ExceptionUtils.getStackTrace(e)); | ||
| setErrorMessage("Failed to clear the input field due to: " + ExceptionUtils.getMessage(e)); |
There was a problem hiding this comment.
Avoid exposing internal exception details in logs/error messages.
Line 53-Line 54 logs full stack trace text and propagates raw exception details to user-visible error messaging.
🛡️ Proposed safer error handling
- logger.warn("Failed to clear the input field: " + ExceptionUtils.getStackTrace(e));
- setErrorMessage("Failed to clear the input field due to: " + ExceptionUtils.getMessage(e));
+ logger.warn("Failed to clear the input field", e);
+ setErrorMessage("Failed to clear the input field.");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@clear_input_field_using_backspace/src/main/java/com/testsigma/addons/web/ClearUsingBackspace.java`
around lines 53 - 54, The code in ClearUsingBackspace currently prints the full
stack trace and raw exception message; replace those with non-sensitive,
user-friendly messages: change logger.warn("Failed to clear the input field: " +
ExceptionUtils.getStackTrace(e)) to a generic warn like logger.warn("Failed to
clear the input field") and, if you need the exception for debugging, log the
stacktrace at debug level (e.g., logger.debug("clear failure", e)). Replace
setErrorMessage("Failed to clear the input field due to: " +
ExceptionUtils.getMessage(e)) with a generic user-facing message such as
setErrorMessage("Failed to clear the input field.") and optionally include a
short, non-sensitive error code or e.getClass().getSimpleName() if you need
minimal diagnostic info.
| @@ -0,0 +1 @@ | |||
| testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjYwMjgiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiNDMifQ.rIHf0f0LSHgKeSgRC-HgRl8tvQHXiBPQbzj1-7XyFb1nvhen_SxrZBwFak4E3Kf1OX4kcavut0mnULWHk-5pBw No newline at end of file | |||
There was a problem hiding this comment.
Remove committed SDK API key from source control immediately.
Line 1 contains a real credential in plaintext. This is a direct secret exposure risk and should be treated as a blocker: rotate the key, remove it from git history, and load it from a secure runtime secret source.
🔐 Proposed safe replacement
-testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjYwMjgiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiNDMifQ.rIHf0f0LSHgKeSgRC-HgRl8tvQHXiBPQbzj1-7XyFb1nvhen_SxrZBwFak4E3Kf1OX4kcavut0mnULWHk-5pBw
+testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@clear_input_field_using_backspace/src/main/resources/testsigma-sdk.properties`
at line 1, The committed file contains a plaintext SDK API key under the
property testsigma-sdk.api.key; remove this secret from the repository
immediately, rotate the exposed key in the provider, purge it from git history
(e.g., git filter-repo or BFG), and replace the hardcoded entry with a secure
runtime lookup (e.g., read testsigma API key from an environment variable or
injected secret manager value and reference that variable name where
testsigma-sdk.api.key was used). Ensure any code that referenced
testsigma-sdk.api.key is updated to read from the new secure source and add the
property name (or env var) to the project's .gitignore and secrets documentation
so future commits do not reintroduce secrets.
Publish this addon as PUBLIC
Addon Name: Clear Input Field Using Backspace
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-11086
Added class to clear the input field using backspace
Summary by CodeRabbit