-
Notifications
You must be signed in to change notification settings - Fork 15
[CUS-10319] Addon nlp to open deep link. #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
| 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(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential NullPointerException if testData value is 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();🤖 Prompt for AI Agents |
||
|
|
||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential NullPointerException if
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 |
||
| 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(); | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential NullPointerException if testData value is null. Same issue as the Android version - 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| logger.info("Opening deep link: " + deepLink); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Object bundleId = iosDriver.getCapabilities().getCapability("appium:bundleId"); | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential NullPointerException if
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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incomplete handling for missing URL scheme and incorrect format specifiers. Multiple issues in this block:
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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. String.format argument count mismatch - will throw exception at runtime. The format string has 4 placeholders ( 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| return Result.FAILED; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| setSuccessMessage(String.format("Successfully opened deep link %s for package %s", | ||||||||||||||||||||||||||||
| deepLink, bundleId)); | ||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Action text references
package-namebut no corresponding input is defined.The
actionTextmentionspackage-nameas a parameter, but there's no@TestDataannotation for it. The implementation usesappPackagefrom capabilities instead. Either removepackage-namefrom the action text or add a corresponding input field.Suggested fix - update action text to match implementation
🤖 Prompt for AI Agents