Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions deeplink_action 1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testsigma.addons</groupId>
<artifactId>deeplink_action</artifactId>
<version>1.0.3</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<testsigma.sdk.version>1.2.24_cloud</testsigma.sdk.version>
<junit.jupiter.version>5.8.0-M1</junit.jupiter.version>
<testsigma.addon.maven.plugin>1.0.0</testsigma.addon.maven.plugin>
<maven.source.plugin.version>3.2.1</maven.source.plugin.version>
<lombok.version>1.18.30</lombok.version>

</properties>

<dependencies>
<dependency>
<groupId>com.testsigma</groupId>
<artifactId>testsigma-java-sdk</artifactId>
<version>${testsigma.sdk.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.33.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>9.4.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.13.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
</dependency>
</dependencies>
<build>
<finalName>deeplink_action</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven.source.plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.testsigma.addons.android;

import com.google.common.collect.ImmutableMap;
import com.testsigma.sdk.AndroidAction;
import com.testsigma.sdk.ApplicationType;
import com.testsigma.sdk.Result;
import com.testsigma.sdk.annotation.Action;
import com.testsigma.sdk.annotation.TestData;
import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openqa.selenium.NoSuchElementException;


@Action(actionText = "Open the deep link test-data for the package package-name",
applicationType = ApplicationType.ANDROID,
useCustomScreenshot = false)
Comment on lines +14 to +16
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

Action text references package-name but no corresponding input is defined.

The actionText mentions package-name as a parameter, but there's no @TestData annotation for it. The implementation uses appPackage from capabilities instead. Either remove package-name from the action text or add a corresponding input field.

Suggested fix - update action text to match implementation
-@Action(actionText = "Open the deep link test-data for the package package-name",
+@Action(actionText = "Open the deep link test-data",
         applicationType = ApplicationType.ANDROID,
         useCustomScreenshot = false)
🤖 Prompt for AI Agents
In `@deeplink_action`
1/src/main/java/com/testsigma/addons/android/OpenDeepLink.java around lines 14 -
16, The actionText in the `@Action` annotation on class OpenDeepLink mentions a
parameter "package-name" that isn't defined; either remove "package-name" from
the actionText or add a `@TestData` field to accept it. Update the
`@Action`(actionText = ...) to stop referencing "package-name" if you intend to
use the existing capability value appPackage, or add a new `@TestData-annotated`
field (e.g., String packageName) and use that in the implementation instead of
appPackage; ensure references in OpenDeepLink's execute logic (appPackage usage)
are adjusted to use the new field if you add it.

public class OpenDeepLink extends AndroidAction {

@TestData(reference = "test-data")
private com.testsigma.sdk.TestData testData;

@Override
protected Result execute() throws NoSuchElementException {
//Your Awesome code starts here
Result result = Result.SUCCESS;
logger.info("Initiating execution");
AndroidDriver androidDriver = (AndroidDriver) this.driver;

String deepLink = testData.getValue().toString();
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

Potential NullPointerException if testData value is null.

testData.getValue() could return null. Consider adding null validation before calling toString().

Suggested fix
-        String deepLink = testData.getValue().toString();
+        Object value = testData.getValue();
+        if (value == null || value.toString().isEmpty()) {
+            setErrorMessage("Deep link test data cannot be null or empty");
+            return Result.FAILED;
+        }
+        String deepLink = value.toString();
🤖 Prompt for AI Agents
In `@deeplink_action`
1/src/main/java/com/testsigma/addons/android/OpenDeepLink.java at line 29, The
assignment to deepLink using testData.getValue().toString() in OpenDeepLink may
throw NPE if testData.getValue() is null; update the code to null-check the
value from testData before calling toString() (e.g., retrieve Object val =
testData.getValue(); if val == null handle appropriately—throw a meaningful
exception or set deepLink to an empty string/default and log a warning) and use
val.toString() only when non-null so the deepLink variable and downstream logic
are safe.


logger.info("Opening deep link: " + deepLink);
String currentPackage = androidDriver.getCurrentPackage();
logger.info("Current package: " + currentPackage);
Object appPackage = androidDriver.getCapabilities().getCapability("appium:appPackage");

try {
androidDriver.executeScript("mobile: deepLink", ImmutableMap.of(
"url", deepLink,
"package", appPackage
));
Comment on lines +34 to +40
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

Potential NullPointerException if appium:appPackage capability is not set.

getCapability("appium:appPackage") can return null if the capability is not present, which would cause issues when passed to ImmutableMap.of() or logged.

Suggested fix
         Object appPackage = androidDriver.getCapabilities().getCapability("appium:appPackage");
+        if (appPackage == null) {
+            appPackage = currentPackage; // fallback to current package
+            logger.info("appium:appPackage capability not found, using current package: " + appPackage);
+        }
 
         try {
🤖 Prompt for AI Agents
In `@deeplink_action`
1/src/main/java/com/testsigma/addons/android/OpenDeepLink.java around lines 34 -
40, The code may NPE when appPackage is null; update OpenDeepLink.java to
null-check the result of
androidDriver.getCapabilities().getCapability("appium:appPackage") (variable
appPackage) before using it in ImmutableMap.of() or in logs, cast it to a String
safely, and build the arguments map conditionally (include the "package" entry
only if appPackage != null) when calling androidDriver.executeScript("mobile:
deepLink", ...); also add a safe log message indicating the package is missing
or the fallback used so execution is explicit.

logger.info("Deep link opened successfully: " + deepLink + " for package: " + appPackage);
} catch (Exception e) {
logger.debug("Error while opening deep link: " + ExceptionUtils.getStackTrace(e));
setErrorMessage(String.format("Failed to open deep link %s for package %s. Error: %s .try with this " +
"package %s",
deepLink, appPackage, e.getMessage(), currentPackage));
return Result.FAILED;
}

setSuccessMessage(String.format("Successfully opened deep link %s for package %s",
deepLink, appPackage));
return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.testsigma.addons.ios;

import com.google.common.collect.ImmutableMap;
import com.testsigma.sdk.ApplicationType;
import com.testsigma.sdk.IOSAction;
import com.testsigma.sdk.Result;
import com.testsigma.sdk.annotation.Action;
import com.testsigma.sdk.annotation.TestData;
import io.appium.java_client.ios.IOSDriver;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openqa.selenium.NoSuchElementException;

import java.util.Map;


@Action(actionText = "Open the deep link test-data",
applicationType = ApplicationType.IOS,
useCustomScreenshot = false)
public class OpenDeepLink extends IOSAction {

@TestData(reference = "test-data")
private com.testsigma.sdk.TestData testData;

@Override
protected Result execute() throws NoSuchElementException {
//Your Awesome code starts here
Result result = Result.SUCCESS;
logger.info("Initiating execution");
IOSDriver iosDriver = (IOSDriver) this.driver;

String deepLink = testData.getValue().toString();
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

Potential NullPointerException if testData value is null.

Same issue as the Android version - testData.getValue() could return null.

Suggested fix
-        String deepLink = testData.getValue().toString();
+        Object value = testData.getValue();
+        if (value == null || value.toString().isEmpty()) {
+            setErrorMessage("Deep link test data cannot be null or empty");
+            return Result.FAILED;
+        }
+        String deepLink = value.toString();
📝 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
String deepLink = testData.getValue().toString();
Object value = testData.getValue();
if (value == null || value.toString().isEmpty()) {
setErrorMessage("Deep link test data cannot be null or empty");
return Result.FAILED;
}
String deepLink = value.toString();
🤖 Prompt for AI Agents
In `@deeplink_action` 1/src/main/java/com/testsigma/addons/ios/OpenDeepLink.java
at line 31, The assignment String deepLink = testData.getValue().toString(); can
NPE if testData.getValue() is null; update the OpenDeepLink code that creates
deepLink (reference testData and variable deepLink) to safely handle null by
checking testData != null and testData.getValue() != null (or use
Objects.toString(testData.getValue(), "") / String.valueOf(testData.getValue()))
before calling toString(), and either throw a clear exception or use a
default/empty string so downstream logic won’t NPE.

logger.info("Opening deep link: " + deepLink);

Object bundleId = iosDriver.getCapabilities().getCapability("appium:bundleId");
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

Potential NullPointerException if appium:bundleId capability is not set.

getCapability("appium:bundleId") can return null, which would cause issues when passed to ImmutableMap.of().

Suggested fix
         Object bundleId = iosDriver.getCapabilities().getCapability("appium:bundleId");
+        if (bundleId == null) {
+            setErrorMessage("appium:bundleId capability is required but not found");
+            return Result.FAILED;
+        }
📝 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
Object bundleId = iosDriver.getCapabilities().getCapability("appium:bundleId");
Object bundleId = iosDriver.getCapabilities().getCapability("appium:bundleId");
if (bundleId == null) {
setErrorMessage("appium:bundleId capability is required but not found");
return Result.FAILED;
}
🤖 Prompt for AI Agents
In `@deeplink_action` 1/src/main/java/com/testsigma/addons/ios/OpenDeepLink.java
at line 34, The call to
iosDriver.getCapabilities().getCapability("appium:bundleId") in
OpenDeepLink.java may return null and will cause problems when passed to
ImmutableMap.of(); update the code in the OpenDeepLink class (where bundleId is
retrieved) to null-check the capability before building the ImmutableMap (or
provide a sensible default or throw a clear IllegalArgumentException), and only
include "bundleId" in the map when non-null so ImmutableMap.of(...) is never
invoked with a null value.

if (!deepLink.contains("://")) {
// No scheme found, construct using appIdentifier as custom URL scheme
logger.debug(String.format("Deep link missing scheme, constructing URL " +
"with appIdentifier: {}://{}", bundleId, deepLink));
setErrorMessage(String.format("Deep link missing scheme, constructing URL " +
"with appIdentifier: {}://{}", bundleId, deepLink));

}
Comment on lines +35 to +42
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

Incomplete handling for missing URL scheme and incorrect format specifiers.

Multiple issues in this block:

  1. Uses {} (SLF4J style) instead of %s for String.format() - placeholders won't be substituted
  2. Sets an error message but continues execution instead of returning or actually constructing the URL
  3. The comment says "construct using appIdentifier" but no construction happens
Suggested fix - either fail or construct the URL
         if (!deepLink.contains("://")) {
             // No scheme found, construct using appIdentifier as custom URL scheme
-            logger.debug(String.format("Deep link missing scheme, constructing URL " +
-                    "with appIdentifier: {}://{}", bundleId, deepLink));
-            setErrorMessage(String.format("Deep link missing scheme, constructing URL " +
-                    "with appIdentifier: {}://{}", bundleId, deepLink));
-
+            setErrorMessage(String.format("Deep link missing scheme. Expected format: scheme://path. Got: %s", deepLink));
+            return Result.FAILED;
         }
📝 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
if (!deepLink.contains("://")) {
// No scheme found, construct using appIdentifier as custom URL scheme
logger.debug(String.format("Deep link missing scheme, constructing URL " +
"with appIdentifier: {}://{}", bundleId, deepLink));
setErrorMessage(String.format("Deep link missing scheme, constructing URL " +
"with appIdentifier: {}://{}", bundleId, deepLink));
}
if (!deepLink.contains("://")) {
// No scheme found, construct using appIdentifier as custom URL scheme
setErrorMessage(String.format("Deep link missing scheme. Expected format: scheme://path. Got: %s", deepLink));
return Result.FAILED;
}
🤖 Prompt for AI Agents
In `@deeplink_action` 1/src/main/java/com/testsigma/addons/ios/OpenDeepLink.java
around lines 35 - 42, In OpenDeepLink, the block that detects a missing URL
scheme both uses SLF4J-style "{}" placeholders with String.format and never
actually constructs or returns a corrected URL; change the String.format calls
to use "%s" placeholders, build a corrected deepLink string by prepending the
app identifier (e.g., bundleId + "://" + deepLink) and assign it back to the
variable used later, and replace the setErrorMessage (or convert it to a
non-error log like logger.info) so execution continues with the constructed URL;
ensure any callers that expect a failure instead are handled by
returning/throwing if you choose that alternative.


try {
iosDriver.executeScript("mobile: deepLink", ImmutableMap.of(
"url", deepLink,
"bundleId", bundleId
));
logger.info("Deep link opened successfully: " + deepLink + " for bundleId: " + bundleId);
} catch (Exception e) {
logger.debug("Error while opening deep link: " + ExceptionUtils.getStackTrace(e));
setErrorMessage(String.format("Failed to open deep link %s for package %s. Error: %s .try with this " +
"package %s",
deepLink, bundleId, e.getMessage()));
Comment on lines +52 to +54
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

String.format argument count mismatch - will throw exception at runtime.

The format string has 4 placeholders (%s) but only 3 arguments are provided (deepLink, bundleId, e.getMessage()). This will cause an IllegalFormatException at runtime.

Fix the format string
-            setErrorMessage(String.format("Failed to open deep link %s for package %s. Error: %s .try with this " +
-                            "package %s",
-                    deepLink, bundleId, e.getMessage()));
+            setErrorMessage(String.format("Failed to open deep link %s for bundleId %s. Error: %s",
+                    deepLink, bundleId, e.getMessage()));
📝 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(String.format("Failed to open deep link %s for package %s. Error: %s .try with this " +
"package %s",
deepLink, bundleId, e.getMessage()));
setErrorMessage(String.format("Failed to open deep link %s for bundleId %s. Error: %s",
deepLink, bundleId, e.getMessage()));
🤖 Prompt for AI Agents
In `@deeplink_action` 1/src/main/java/com/testsigma/addons/ios/OpenDeepLink.java
around lines 52 - 54, The format string in OpenDeepLink.setErrorMessage call has
four %s placeholders but only three arguments (deepLink, bundleId,
e.getMessage()), causing IllegalFormatException; either remove the extra "%s" so
the message uses three placeholders or add the missing fourth argument (e.g.,
bundleId again) to the String.format call in the setErrorMessage invocation
inside the OpenDeepLink class/method.

return Result.FAILED;
}

setSuccessMessage(String.format("Successfully opened deep link %s for package %s",
deepLink, bundleId));
return result;
}

}