From 829e77210fdb651b542e47e994d796f5aa7ad3e9 Mon Sep 17 00:00:00 2001 From: prklm10 Date: Wed, 27 Mar 2024 16:21:37 +0530 Subject: [PATCH] adding testcase and execution id --- .../java/io/percy/appium/lib/CliWrapper.java | 5 ++++- .../io/percy/appium/lib/ScreenshotOptions.java | 18 ++++++++++++++++++ .../appium/providers/GenericProvider.java | 4 +++- src/test/java/io/percy/appium/checkstyles.xml | 2 +- .../appium/lib/ScreenshotOptionsTest.java | 15 ++++++++++++++- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/percy/appium/lib/CliWrapper.java b/src/main/java/io/percy/appium/lib/CliWrapper.java index b7b0d2f..2acadb6 100644 --- a/src/main/java/io/percy/appium/lib/CliWrapper.java +++ b/src/main/java/io/percy/appium/lib/CliWrapper.java @@ -88,7 +88,8 @@ public boolean healthcheck() { * unique. */ public JSONObject postScreenshot(String name, JSONObject tag, List tiles, String externalDebugUrl, - JSONObject ignoredElementsData, JSONObject consideredElementsData, Boolean sync) { + JSONObject ignoredElementsData, JSONObject consideredElementsData, Boolean sync, String testCase, + String thTestCaseExecutionId) { // Build a JSON object to POST back to the cli node process JSONObject data = new JSONObject(); data.put("name", name); @@ -100,6 +101,8 @@ public JSONObject postScreenshot(String name, JSONObject tag, List tiles, data.put("clientInfo", env.getClientInfo(false)); data.put("environmentInfo", env.getEnvironmentInfo()); data.put("sync", sync); + data.put("testCase", testCase); + data.put("thTestCaseExecutionId", thTestCaseExecutionId); int timeout = 600000; // 600 seconds = 600,000 milliseconds // Create RequestConfig with timeout diff --git a/src/main/java/io/percy/appium/lib/ScreenshotOptions.java b/src/main/java/io/percy/appium/lib/ScreenshotOptions.java index b3cee21..0046f1c 100644 --- a/src/main/java/io/percy/appium/lib/ScreenshotOptions.java +++ b/src/main/java/io/percy/appium/lib/ScreenshotOptions.java @@ -17,6 +17,8 @@ public class ScreenshotOptions { private Boolean fullScreen = false; private Integer screenLengths = 4; private @Nullable Boolean sync = null; + private String testCase = null; + private String thTestCaseExecutionId = null; private List ignoreRegionXpaths = new ArrayList(); private List ignoreRegionAccessibilityIds = new ArrayList(); private List ignoreRegionAppiumElements = new ArrayList(); @@ -54,6 +56,14 @@ public String getOrientation() { return orientation; } + public String getTestCase() { + return testCase; + } + + public String getThTestCaseExecutionId() { + return thTestCaseExecutionId; + } + public Boolean getFullPage() { return fullPage; } @@ -110,6 +120,14 @@ public void setSync(Boolean sync) { this.sync = sync; } + public void setTestCase(String testCase) { + this.testCase = testCase; + } + + public void setThTestCaseExecutionId(String thTestCaseExecutionId) { + this.thTestCaseExecutionId = thTestCaseExecutionId; + } + public List getIgnoreRegionXpaths() { return ignoreRegionXpaths; } diff --git a/src/main/java/io/percy/appium/providers/GenericProvider.java b/src/main/java/io/percy/appium/providers/GenericProvider.java index d53d692..a02b67e 100644 --- a/src/main/java/io/percy/appium/providers/GenericProvider.java +++ b/src/main/java/io/percy/appium/providers/GenericProvider.java @@ -136,7 +136,9 @@ public JSONObject screenshot(String name, ScreenshotOptions options, debugUrl, getObjectForArray("ignoreElementsData", ignoreRegions), getObjectForArray("considerElementsData", considerRegions), - options.getSync()); + options.getSync(), + options.getTestCase(), + options.getThTestCaseExecutionId()); } public void setMetadata(Metadata metadata) { diff --git a/src/test/java/io/percy/appium/checkstyles.xml b/src/test/java/io/percy/appium/checkstyles.xml index 353cc00..f8fa71e 100644 --- a/src/test/java/io/percy/appium/checkstyles.xml +++ b/src/test/java/io/percy/appium/checkstyles.xml @@ -118,7 +118,7 @@ - + diff --git a/src/test/java/io/percy/appium/lib/ScreenshotOptionsTest.java b/src/test/java/io/percy/appium/lib/ScreenshotOptionsTest.java index a2276a2..0d9ba24 100644 --- a/src/test/java/io/percy/appium/lib/ScreenshotOptionsTest.java +++ b/src/test/java/io/percy/appium/lib/ScreenshotOptionsTest.java @@ -41,7 +41,20 @@ public void testCastMobileElementsToWebElements() { public void testSyncOption() { ScreenshotOptions options = new ScreenshotOptions(); - // Create a list of MobileElements assertEquals(options.getSync(), null); } + + @Test + public void testTestCase() { + ScreenshotOptions options = new ScreenshotOptions(); + + assertEquals(options.getTestCase(), null); + } + + @Test + public void testThTestCaseExecutionId() { + ScreenshotOptions options = new ScreenshotOptions(); + + assertEquals(options.getThTestCaseExecutionId(), null); + } }