Skip to content

[CUS-12573] hides keyboard fastly in ios devices.#389

Open
ManojTestsigma wants to merge 1 commit into
devfrom
CUS-12573
Open

[CUS-12573] hides keyboard fastly in ios devices.#389
ManojTestsigma wants to merge 1 commit into
devfrom
CUS-12573

Conversation

@ManojTestsigma
Copy link
Copy Markdown
Contributor

@ManojTestsigma ManojTestsigma commented May 8, 2026

please review this addon and publish as PUBLIC

Addon name : hide_keyboard
Addon accont: https://jarvis.testsigma.com/ui/tenants/3072/addons
Jira: https://testsigma.atlassian.net/browse/CUS-12573

fix

reduced the time for isKeyboardShown method from 5 seconds to 2 seconds.

Summary by CodeRabbit

  • New Features
    • Added iOS keyboard hiding action with multiple dismissal strategies (return key, tap above keyboard, action buttons, accessibility ID) for reliable on-screen keyboard management during iOS test execution.

@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 May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a new iOS test automation module hide_keyboard with a multi-strategy action class that dismisses the on-screen keyboard. It includes Maven build configuration with required dependencies, an implementation with four sequential keyboard-hiding strategies, and SDK configuration.

Changes

iOS Hide Keyboard Module

Layer / File(s) Summary
Build Configuration
hide_keyboard/pom.xml
Maven project configuration with Java 11 target, dependency versions for TestSigma SDK, Selenium, Appium, Jackson, Lombok, and testing libraries; build plugins for shaded jar generation and source attachment.
Core Execution Logic
hide_keyboard/src/main/java/com/testsigma/addons/ios/HideKeyboard.java
execute() method orchestrates up to four keyboard-hiding strategies in sequence, logs execution time per strategy, checks keyboard visibility after each attempt via isKeyboardShown(), and returns Result.SUCCESS or Result.FAILED accordingly.
Keyboard Dismissal Strategies
hide_keyboard/src/main/java/com/testsigma/addons/ios/HideKeyboard.java
Four strategy methods implement different keyboard dismissal approaches: returnStrategy() sends Keys.RETURN, tapAboveKeyboardStrategy() performs touch gesture above keyboard element, clickKeyboardKeysStrategy() attempts clicking action keys (Return/Done/Search/Next/Go), and hideKeyboardAccessibilityIDStrategy() clicks via accessibility ID.
SDK Configuration
hide_keyboard/src/main/resources/testsigma-sdk.properties
Properties file containing TestSigma SDK API key.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 Hop, hop, keyboards do hide,
Four strategies we've tried and tried,
With Return key and touch so light,
The iOS screen goes out of sight!

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title correctly identifies the main change: implementing keyboard hiding functionality for iOS devices, which aligns with the added HideKeyboard class and pom.xml configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch CUS-12573

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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@hide_keyboard/src/main/java/com/testsigma/addons/ios/HideKeyboard.java`:
- Around line 97-110: The implicit wait is being overwritten to 0
unconditionally; wrap the short-lived change in a try/finally and restore the
prior implicit-wait after the click attempts: before calling
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1)) capture the
current implicit wait into a variable (e.g., prevImplicit), set the 1-second
timeout, perform the List.of(...).forEach(...) clicks, and in a finally block
restore the saved prevImplicit via
driver.manage().timeouts().implicitlyWait(prevImplicit); update the code around
the driver.manage().timeouts().implicitlyWait(...) calls in HideKeyboard (the
block that sets to 1s and later to 0) so the original timeout is always
reinstated even on exceptions.
- Around line 123-132: The isKeyboardShown() method currently catches all
exceptions and returns false, which masks driver errors and can cause execute()
to incorrectly treat failures as success; change isKeyboardShown() to stop
swallowing exceptions—catch only expected exceptions if needed but otherwise log
the error and rethrow (e.g., throw new RuntimeException(e)) so execute()
surfaces the failure instead of receiving a false; keep the implicit wait
adjustments and ensure any thrown exception carries context about the keyboard
check.

In `@hide_keyboard/src/main/resources/testsigma-sdk.properties`:
- Line 1: Remove the hard-coded API key value for testsigma-sdk.api.key from
testsigma-sdk.properties and replace it with a runtime secret reference (e.g.,
read from an environment variable or secret manager); update any code that reads
testsigma-sdk.api.key to fallback to process/env lookup (or equivalent in your
runtime) and ensure CI injects the secret. After replacing the file, rotate the
exposed credential immediately and purge the leaked value from git history (git
filter-repo/BFG) before merging to prevent further exposure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 99d671fb-ec52-4409-8aaf-cdef9ac4533b

📥 Commits

Reviewing files that changed from the base of the PR and between 3356296 and f1f0702.

📒 Files selected for processing (3)
  • hide_keyboard/pom.xml
  • hide_keyboard/src/main/java/com/testsigma/addons/ios/HideKeyboard.java
  • hide_keyboard/src/main/resources/testsigma-sdk.properties

Comment on lines +97 to +110
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
List.of("Return", "return", "done", "Done", "search", "Search", "Next", "next", "Go", "go").forEach(button -> {
try {
driver.findElement(By.xpath("//*[contains(@name, '" + button + "')]")).click();
} catch (Exception e) {
logger.info("XPath click failed for key '" + button + "': " + e.getMessage());
}
try {
driver.findElement(AppiumBy.name(button)).click();
} catch (Exception e) {
logger.info("Name lookup failed for key '" + button + "': " + e.getMessage());
}
});
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(0));
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 | ⚡ Quick win

Restore implicit wait safely; avoid leaking driver timeout state.

Lines 110 and 127 unconditionally set implicit wait to 0. If another timeout was configured before this action, it gets clobbered and can affect later steps.

Suggested fix pattern
- driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
- // ... operations ...
- driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(0));
+ Duration previous = driver.manage().timeouts().getImplicitWaitTimeout();
+ try {
+   driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
+   // ... operations ...
+ } finally {
+   driver.manage().timeouts().implicitlyWait(previous);
+ }

Also applies to: 125-127

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hide_keyboard/src/main/java/com/testsigma/addons/ios/HideKeyboard.java`
around lines 97 - 110, The implicit wait is being overwritten to 0
unconditionally; wrap the short-lived change in a try/finally and restore the
prior implicit-wait after the click attempts: before calling
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1)) capture the
current implicit wait into a variable (e.g., prevImplicit), set the 1-second
timeout, perform the List.of(...).forEach(...) clicks, and in a finally block
restore the saved prevImplicit via
driver.manage().timeouts().implicitlyWait(prevImplicit); update the code around
the driver.manage().timeouts().implicitlyWait(...) calls in HideKeyboard (the
block that sets to 1s and later to 0) so the original timeout is always
reinstated even on exceptions.

Comment on lines +123 to +132
private boolean isKeyboardShown() {
try {
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
boolean shown = ((IOSDriver) driver).isKeyboardShown();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(0));
return shown;
} catch (Exception e) {
logger.info("Exception while checking keyboard visibility: " + e.getMessage());
return false;
}
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 | ⚡ Quick win

Do not treat keyboard-check exceptions as “keyboard hidden.”

In Line 131, returning false on exception can produce a false SUCCESS in execute(). This should fail closed (or surface failure) instead of masking driver/check errors.

Suggested fix
 private boolean isKeyboardShown() {
     try {
         driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
         boolean shown = ((IOSDriver) driver).isKeyboardShown();
         driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(0));
         return shown;
     } catch (Exception e) {
         logger.info("Exception while checking keyboard visibility: " + e.getMessage());
-        return false;
+        return true; // fail-closed: don't report hidden when check failed
     }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hide_keyboard/src/main/java/com/testsigma/addons/ios/HideKeyboard.java`
around lines 123 - 132, The isKeyboardShown() method currently catches all
exceptions and returns false, which masks driver errors and can cause execute()
to incorrectly treat failures as success; change isKeyboardShown() to stop
swallowing exceptions—catch only expected exceptions if needed but otherwise log
the error and rethrow (e.g., throw new RuntimeException(e)) so execute()
surfaces the failure instead of receiving a false; keep the implicit wait
adjustments and ensure any thrown exception carries context about the keyboard
check.

@@ -0,0 +1 @@
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNDBkMjhiNS0xNmUwLThlNmYtOWQ0ZS05MjYxMGNiZTcyYzciLCJ1bmlxdWVJZCI6IjYxODUiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiNDMifQ.Ktf9Ejac32ZAAKDwJFa9NerBc-xymkf_msZ0sr2C-o7gQ6tI1F8UVdfUYHwjGDY2P3R_4_7JZ4dIQ-lnL5Xceg 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 | ⚡ Quick win

Remove the committed API key from source control before merge.

Line 1 exposes a real credential in plaintext. For a PUBLIC addon, this is a release blocker and a credential-compromise risk. Replace this with runtime secret injection (env var / secure vault / CI secret), rotate this key immediately, and purge it from git history.

Suggested secure change
-testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNDBkMjhiNS0xNmUwLThlNmYtOWQ0ZS05MjYxMGNiZTcyYzciLCJ1bmlxdWVJZCI6IjYxODUiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiNDMifQ.Ktf9Ejac32ZAAKDwJFa9NerBc-xymkf_msZ0sr2C-o7gQ6tI1F8UVdfUYHwjGDY2P3R_4_7JZ4dIQ-lnL5Xceg
+testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}
📝 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
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNDBkMjhiNS0xNmUwLThlNmYtOWQ0ZS05MjYxMGNiZTcyYzciLCJ1bmlxdWVJZCI6IjYxODUiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiNDMifQ.Ktf9Ejac32ZAAKDwJFa9NerBc-xymkf_msZ0sr2C-o7gQ6tI1F8UVdfUYHwjGDY2P3R_4_7JZ4dIQ-lnL5Xceg
testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hide_keyboard/src/main/resources/testsigma-sdk.properties` at line 1, Remove
the hard-coded API key value for testsigma-sdk.api.key from
testsigma-sdk.properties and replace it with a runtime secret reference (e.g.,
read from an environment variable or secret manager); update any code that reads
testsigma-sdk.api.key to fallback to process/env lookup (or equivalent in your
runtime) and ensure CI injects the secret. After replacing the file, rotate the
exposed credential immediately and purge the leaked value from git history (git
filter-repo/BFG) before merging to prevent further exposure.

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