Skip to content

Commit 184cf24

Browse files
Merge pull request #28 from testsigmahq/1.2.0-release
v1.2.0 release
2 parents d35c5b8 + 4d51d9b commit 184cf24

File tree

175 files changed

+1670
-530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+1670
-530
lines changed

automator/src/com/testsigma/automator/actions/mobile/MobileElement.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ public MobileElement(Node node, Integer depth, Platform platform) {
221221

222222
private void populateIosAttributes(RemoteWebElement remoteWebElement) {
223223
this.setName(remoteWebElement.getAttribute("name"));
224-
this.setAccessibilityId(this.name);
224+
this.setId(name);
225+
this.setAccessibilityId(name);
225226
this.setType(remoteWebElement.getAttribute("type"));
226227
this.setLabel(remoteWebElement.getAttribute("label"));
227228
}
@@ -230,6 +231,7 @@ private void populateAndroidAttributes(RemoteWebElement remoteWebElement) {
230231
this.setName(remoteWebElement.getTagName());
231232
this.setType(remoteWebElement.getAttribute("class"));
232233
this.setResourceId(remoteWebElement.getAttribute("resource-id"));
234+
this.setId(resourceId);
233235
this.setContentDesc(remoteWebElement.getAttribute("content-desc"));
234236
this.setAccessibilityId(this.contentDesc);
235237
this.setPassword(Boolean.valueOf(remoteWebElement.getAttribute("password")));

automator/src/com/testsigma/automator/constants/AutomatorMessages.java

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class AutomatorMessages {
2727
public final static String MSG_CONDITION_ELSE_IF_SUCCESS = "\"Else If\" condition matched to proceed with the steps under this condition.";
2828
public final static String MSG_CONDITION_ELSE_SUCCESS = "\"Else\" condition matched to proceed with the steps under this condition.";
2929
public static final String EXCEPTION_WEBDRIVER_NOTCREATED = "Unable to create a new Test Session due to unexpected failure(0x537). Please contact Support for more details.";
30+
public static final String NO_PARALLEL_RUNS = "Parallel Executions Limit exceeded.Please upgrade to community edition for more parallel runs or Please contact support team for more details.";
3031
public static final String EXCEPTION_INVALID_PARAMETER_FORMAT = "Invalid value ?1 entered for parameter ?2 while executing the Custom Test Data Function \"?3\"";
3132
public static final String EXCEPTION_INVALID_CLASS_NAME = "Unsupported class \"?1\" used to generate test data from custom function";
3233
public static final String EXCEPTION_METHOD_NOT_FOUND = "No implementation found for this template";

automator/src/com/testsigma/automator/constants/ErrorCodes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ErrorCodes {
3737
public static Integer ERROR_TEST_DATA_FAILURE = 103;
3838
public static Integer ERROR_ELEMENT_FAILURE = 104;
3939
public static Integer BROWSER_VERSION_NOT_AVAILABLE = 109;
40-
40+
public static Integer NO_PARALLEL_RUN = 110;
4141
public static Integer TEST_CASE_DETAILS_FETCH_FAILED = 200;
4242

4343
public static Integer WDA_INSTALLATION_FAILED = 300;

automator/src/com/testsigma/automator/drivers/DriverManager.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.testsigma.automator.constants.SessionErrorType;
88
import com.testsigma.automator.entity.*;
99
import com.testsigma.automator.exceptions.AutomatorException;
10+
import com.testsigma.automator.exceptions.TestsigmaNoParallelRunException;
1011
import com.testsigma.automator.runners.EnvironmentRunner;
1112
import com.testsigma.automator.utilities.RuntimeDataProvider;
1213
import com.testsigma.automator.utilities.TimeUtil;
@@ -22,7 +23,7 @@
2223
@Data
2324
public abstract class DriverManager {
2425
public static final String MSG_LAB_MINUTES_EXCEEDED = "Allowed test execution duration on cloud devices/machines exceeded.";
25-
public static final String MSG_NO_PARALLEL_RUN = "Parallel runs are not allowed in Open Source, Please Change to Community edition for parallel Execution or Contact Support Team.";
26+
public static final String MSG_NO_PARALLEL_RUN = "Parallel Executions Limit exceeded.Please upgrade to community edition for more parallel runs.";
2627
public static final String MSG_OS_NOT_SUPPORTED = "Selected device OS and version combination is no longer supported. Please edit the device and choose a supported OS and Version.";
2728
public static final String MSG_BROWSER_NOT_SUPPORTED = "Selected browser and version combination is no longer supported. Please edit the device and choose a supported browser and Version.";
2829

@@ -136,7 +137,10 @@ public void startSession(DriverSessionType driverSessionType, Long entityId, Boo
136137
String errorMessage = parseErrorMessage(e.getMessage());
137138
if (StringUtils.isBlank(errorMessage)) {
138139
errorMessage = AutomatorMessages.EXCEPTION_WEBDRIVER_NOTCREATED + " - " + e.getMessage();
139-
} else {
140+
} else if(e.getMessage().contains("NO_PARALLEL_RUN")){
141+
errorMessage = AutomatorMessages.NO_PARALLEL_RUNS;
142+
throw new TestsigmaNoParallelRunException(ErrorCodes.NO_PARALLEL_RUN,errorMessage);
143+
}else {
140144
errorMessage = "Unable to create a new Test Session due to unexpected failure(0x537). " + errorMessage;
141145
}
142146
endSession();

automator/src/com/testsigma/automator/entity/StepDetails.java

+1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ public class StepDetails {
3333
private Long parentId;
3434
private String testDataName;
3535
private String testDataValue;
36+
private Boolean ignoreStepResult;
3637
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.testsigma.automator.exceptions;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
import lombok.extern.log4j.Log4j2;
6+
7+
8+
@Log4j2
9+
@Getter
10+
@Setter
11+
public class TestsigmaNoParallelRunException extends AutomatorException {
12+
13+
private Integer errorCode;
14+
private String message;
15+
private String dispMessage;
16+
17+
public TestsigmaNoParallelRunException(Integer errorCode, String message) {
18+
super(errorCode, message);
19+
this.errorCode = errorCode;
20+
this.message = message;
21+
this.dispMessage = message;
22+
log.error(message);
23+
}
24+
}

automator/src/com/testsigma/automator/runners/ActionStepExecutor.java

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ private void markTestcaseAborted(TestCaseResult testCaseResult, TestCaseStepResu
117117
result.setMessage(AutomatorMessages.MSG_STEP_MAJOR_STEP_FAILURE);
118118
testCaseResult.setResult(ResultConstant.ABORTED);
119119
testCaseResult.setMessage(AutomatorMessages.MSG_TEST_CASE_ABORTED);
120+
if(!testCaseStepEntity.getStepDetails().getIgnoreStepResult()) {
121+
testCaseResult.setResult(ResultConstant.ABORTED);
122+
testCaseResult.setMessage(AutomatorMessages.MSG_TEST_CASE_ABORTED);
123+
}
120124
} else {
121125
result.setResult(ResultConstant.FAILURE);
122126
}

automator/src/com/testsigma/automator/runners/AddonNaturalTextActionStepExecutor.java

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ private void markTestcaseAborted(TestCaseResult testCaseResult, TestCaseStepResu
7878
result.setMessage(AutomatorMessages.MSG_STEP_MAJOR_STEP_FAILURE);
7979
testCaseResult.setResult(ResultConstant.ABORTED);
8080
testCaseResult.setMessage(AutomatorMessages.MSG_TEST_CASE_ABORTED);
81+
if(!testCaseStepEntity.getStepDetails().getIgnoreStepResult()) {
82+
testCaseResult.setResult(ResultConstant.ABORTED);
83+
testCaseResult.setMessage(AutomatorMessages.MSG_TEST_CASE_ABORTED);
84+
}
8185
} else {
8286
result.setResult(ResultConstant.FAILURE);
8387
}

automator/src/com/testsigma/automator/runners/EnvironmentRunner.java

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.testsigma.automator.drivers.DriversUpdateService;
77
import com.testsigma.automator.entity.*;
88
import com.testsigma.automator.exceptions.AutomatorException;
9+
import com.testsigma.automator.exceptions.TestsigmaNoParallelRunException;
910
import com.testsigma.automator.http.HttpClient;
1011
import com.testsigma.automator.utilities.ErrorUtil;
1112
import com.testsigma.automator.utilities.PathUtil;
@@ -117,6 +118,10 @@ public EnvironmentRunResult run() {
117118
afterExecute();
118119
setEnvironmentResult();
119120
setStoppedStatus();
121+
} catch (TestsigmaNoParallelRunException e){
122+
environmentRunResult.setResult(ResultConstant.STOPPED);
123+
environmentRunResult.setErrorCode(e.getErrorCode());
124+
environmentRunResult.setMessage(e.getMessage());
120125
} catch (AutomatorException e) {
121126
environmentRunResult.setResult(ResultConstant.NOT_EXECUTED);
122127
environmentRunResult.setErrorCode(e.getErrorCode());

automator/src/com/testsigma/automator/runners/TestcaseRunner.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ public TestCaseResult run() throws Exception {
198198
}
199199

200200
//TODO:use check based step type
201-
if (testCaseStepEntity.getConditionType() == null || testCaseStepEntity.getConditionType() == ConditionType.NOT_USED
202-
|| ConditionType.LOOP_FOR == testCaseStepEntity.getConditionType()) {
201+
if ((testCaseStepEntity.getConditionType() == null || testCaseStepEntity.getConditionType() == ConditionType.NOT_USED
202+
|| ConditionType.LOOP_FOR == testCaseStepEntity.getConditionType()) && (!testCaseStepEntity.getStepDetails().getIgnoreStepResult()) ) {
203203
result = (result.getId() < testCaseStepResult.getResult().getId()) ? testCaseStepResult.getResult() : result;
204204
}
205205
int processedSteps = processedStepCount(testCaseStepsResult);

automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public TestCaseStepResult run(TestCaseStepEntity testCaseStepEntity, TestCaseSte
219219
boolean hasToAbortTestcase = (majorFailure && !isGroupStep && !isStepGroup);
220220

221221
if (!testCaseStepResult.getSkipExe() && hasToAbortTestcase) {
222-
setFailedMessage(testCaseStepResult, testCaseResult);
222+
setFailedMessage(testCaseStepResult, testCaseResult, testCaseStepEntity.getStepDetails().getIgnoreStepResult());
223223
}
224224
//Add Loop level result
225225
if (testCaseStepEntity.getType() == TestStepType.BREAK_LOOP && status == ResultConstant.SUCCESS) {
@@ -468,9 +468,11 @@ private void executeGroup(TestCaseStepEntity testcaseStep, TestCaseStepResult re
468468
stepResults.add(childStepResult);
469469

470470
log.debug("Result in Step Group :::: " + objectMapperService.convertToJson(childStepResult));
471-
if (childStep.getConditionType() == null || childStep.getConditionType() == ConditionType.NOT_USED || ConditionType.LOOP_FOR == (childStep.getConditionType())) {
471+
if ((childStep.getConditionType() == null || childStep.getConditionType() == ConditionType.NOT_USED ||
472+
ConditionType.LOOP_FOR == (childStep.getConditionType()))&& (!childStep.getStepDetails().getIgnoreStepResult())) {
472473
status = (status.getId() < childStepResult.getResult().getId()) ? childStepResult.getResult() : status;
473474
}
475+
474476
boolean isMajorStepFailure = isStepGroup && isStepGroupFailure(testcaseStep, childStep, childStepResult);
475477

476478
if (!skipExe && isMajorStepFailure && isMajorStepGroupFailure) {
@@ -479,7 +481,7 @@ private void executeGroup(TestCaseStepEntity testcaseStep, TestCaseStepResult re
479481
.append((childStepResult.getMessage() != null) ? childStepResult.getMessage() + "." : "")
480482
.append(AutomatorMessages.MSG_CHECK_FOR_MORE_DETAILS).toString();
481483
result.setMessage(majorMessage);
482-
setFailedMessage(childStepResult, tresult);
484+
setFailedMessage(childStepResult, tresult, testcaseStep.getStepDetails().getIgnoreStepResult());
483485
}
484486
skipExe = childStepResult.getSkipExe();
485487
message = childStepResult.getSkipMessage();
@@ -521,21 +523,24 @@ protected void populateLoopConditionResult(TestCaseStepResult parentLoopResult,
521523
}
522524
}
523525

524-
private void setFailedMessage(TestCaseStepResult result, TestCaseResult testCaseResult) throws AutomatorException {
526+
private void setFailedMessage(TestCaseStepResult result, TestCaseResult testCaseResult, Boolean ignoreStepResult) throws AutomatorException {
525527

526528
result.setSkipExe(true);
527-
testCaseResult.setResult(ResultConstant.FAILURE);
528-
String majorMessage = AutomatorMessages.MSG_STEP_MAJOR_STEP_FAILURE +
529-
((result.getMessage() != null) ? result.getMessage() : "") + " . " + AutomatorMessages.MSG_CHECK_FOR_MORE_DETAILS;
530-
testCaseResult.setMessage(majorMessage);
531529
result.setSkipMessage(AutomatorMessages.MSG_STEP_MAJOR_STEP_FAILURE);
530+
if(!ignoreStepResult) {
531+
String majorMessage = AutomatorMessages.MSG_STEP_MAJOR_STEP_FAILURE +
532+
((result.getMessage() != null) ? result.getMessage() : "") + " . " + AutomatorMessages.MSG_CHECK_FOR_MORE_DETAILS;
533+
testCaseResult.setMessage(majorMessage);
534+
testCaseResult.setResult(ResultConstant.FAILURE);
535+
}
532536
}
533537

534538
private boolean isStepGroupFailure(TestCaseStepEntity testcaseStep, TestCaseStepEntity childStep,
535539
TestCaseStepResult childStepResult) {
536540
return childStep.getPriority() == TestStepPriority.MAJOR &&
537541
childStepResult.getResult() != null && !childStepResult.getResult().equals(ResultConstant.SUCCESS)
538-
&& (testcaseStep.getConditionType() == null || !testcaseStep.getConditionType().equals(ConditionType.LOOP_FOR));
542+
&& (testcaseStep.getConditionType() == null || !testcaseStep.getConditionType().equals(ConditionType.LOOP_FOR))
543+
&& !childStep.getStepDetails().getIgnoreStepResult();
539544
}
540545

541546

automator/src/com/testsigma/automator/runners/TestsuiteRunner.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package com.testsigma.automator.runners;
22

33
import com.testsigma.automator.AutomatorConfig;
4+
import com.testsigma.automator.constants.AutomatorMessages;
45
import com.testsigma.automator.constants.DriverSessionType;
56
import com.testsigma.automator.constants.ErrorCodes;
6-
import com.testsigma.automator.constants.AutomatorMessages;
77
import com.testsigma.automator.drivers.DriverManager;
88
import com.testsigma.automator.entity.*;
99
import com.testsigma.automator.exceptions.AutomatorException;
10+
import com.testsigma.automator.exceptions.TestsigmaNoParallelRunException;
1011
import com.testsigma.automator.http.HttpClient;
1112
import com.testsigma.automator.utilities.ErrorUtil;
1213
import lombok.Data;
@@ -189,6 +190,12 @@ private void runSuite(TestSuiteEntity testSuiteEntity, TestSuiteResult testSuite
189190
testCaseEntity = getTestCase(testCaseEntity, this.testCaseFetchMaxTries);
190191
new ErrorUtil().checkError(testCaseEntity.getErrorCode(), testCaseEntity.getMessage());
191192
}
193+
} catch (TestsigmaNoParallelRunException e) {
194+
log.error(e.getMessage(), e);
195+
testCaseRunFailed = true;
196+
resultFailureMessage = e.getMessage();
197+
testCaseResult.setResult(ResultConstant.STOPPED);
198+
testCaseResult.setMessage(resultFailureMessage);
192199
} catch (AutomatorException e) {
193200
log.error(e.getMessage(), e);
194201
testCaseRunFailed = true;

automator/src/com/testsigma/automator/utilities/ErrorUtil.java

+6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package com.testsigma.automator.utilities;
22

33
import com.testsigma.automator.constants.ErrorCodes;
4+
import com.testsigma.automator.constants.SessionErrorType;
45
import com.testsigma.automator.exceptions.AutomatorException;
6+
import com.testsigma.automator.exceptions.TestsigmaNoParallelRunException;
57

68
public class ErrorUtil {
79

810
public static final String EXCEPTION_INVALID_DEVICES = "Only a limited set of devices are available in the selected Plan. To select any of the available devices, please upgrade to a higher plan";
911
public static final String EXCEPTION_INVALID_BROWSERS = "Only latest Browser versions are available in the selected Plan. To select older Browser versions,please upgrade to a higher plan";
1012
public static final String EXCEPTION_REST_AUTOMATION = "To execute Rest API Tests, please upgrade to a higher plan";
1113
public static final String EXCEPTION_MOBILE_AUTOMATION = "To execute Mobile Application Tests, please upgrade to a higher plan";
14+
public static final String MSG_NO_PARALLEL_RUN = "Parallel Executions Limit exceeded.Please upgrade to community edition for more parallel runs.";
1215
public static final String UNKOWN_ERROR = "Unexpected error occurred";
1316
public static final String BROWSER_VERSION_NOT_AVILABLE = "Selected Browser Version is not available in your Local.";
1417

@@ -37,6 +40,9 @@ public void checkError(Integer error, String message) throws AutomatorException
3740
} else if (ErrorCodes.BROWSER_VERSION_NOT_AVAILABLE.equals(error)) {
3841
throw new AutomatorException(ErrorCodes.BROWSER_VERSION_NOT_AVAILABLE,
3942
BROWSER_VERSION_NOT_AVILABLE);
43+
} else if (ErrorCodes.NO_PARALLEL_RUN.equals(error)) {
44+
throw new TestsigmaNoParallelRunException(ErrorCodes.NO_PARALLEL_RUN,
45+
MSG_NO_PARALLEL_RUN);
4046
} else {
4147
message = (message != null) ? message : UNKOWN_ERROR;
4248
throw new AutomatorException(error, message);

automator/src/com/testsigma/automator/webservices/RestAPIRunTimeDataProcessor.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.apache.commons.lang3.StringUtils;
1616

1717
import java.util.ArrayList;
18+
import java.util.HashMap;
1819
import java.util.List;
1920
import java.util.Map;
2021
import java.util.regex.Matcher;
@@ -145,41 +146,49 @@ private void updateRequestAuthorizationRuntimeValues() throws AutomatorException
145146
}
146147
}
147148

148-
public void storeResponseData(HttpResponse<String> response) throws AutomatorException {
149+
public void storeResponseData(HttpResponse<String> response,Map<String,String> envSettings) throws AutomatorException {
149150
String responseStr = response.getResponseText();
150151
Map<String, String> responseHeadersMap = response.getHeadersMap();
151152
String responseHeaders = new ObjectMapperService().convertToJson(responseHeadersMap);
152-
storeRuntimeVariblesJsonPath(restfulStepEntity.getHeaderRuntimeData(), responseHeaders);
153-
storeRuntimeVariblesJsonPath(restfulStepEntity.getBodyRuntimeData(), responseStr);
153+
storeRuntimeVariblesJsonPath(restfulStepEntity.getHeaderRuntimeData(), responseHeaders,envSettings);
154+
storeRuntimeVariblesJsonPath(restfulStepEntity.getBodyRuntimeData(), responseStr,envSettings);
154155
}
155156

156-
private void storeRuntimeVariblesJsonPath(String expectedStr, String actualStr) throws AutomatorException{
157+
private void storeRuntimeVariblesJsonPath(String expectedStr, String actualStr,Map<String,String> envSettings) throws AutomatorException{
157158

158159
if (StringUtils.isNotBlank(expectedStr) && StringUtils.isNotBlank(actualStr)) {
159160
boolean jsonPathValidationsFailed = false;
160161
List<String> failedJsonPathsList = new ArrayList<>();
162+
Map<String,String> runtimeVariablesMap = new HashMap<>();
163+
boolean isPathNotFound = false;
164+
String exceptionStr = "";
161165
Map<String, String> pathMap = new ObjectMapperService().parseJson(expectedStr, new TypeReference<>() {
162166
});
163167
for (Map.Entry<String, String> map : pathMap.entrySet()) {
164168
String name = map.getKey();
165169
String path = map.getValue();
166-
Object pathResult;
167170
try {
171+
Object pathResult;
168172
if (path.equals(JSON_PATH_ALL)) {
169173
pathResult = actualStr;
170174
} else {
171175
pathResult = JsonPath.parse(actualStr).read(path);
172176
}
173177
new RuntimeDataProvider().storeRuntimeVariable(name, pathResult.toString());
178+
runtimeVariablesMap.put(name,String.valueOf(pathResult));
174179
} catch (PathNotFoundException e) {
175180
jsonPathValidationsFailed = true;
176181
failedJsonPathsList.add(path);
182+
exceptionStr = exceptionStr+", <br>"+name+"="+path;
177183
log.error("JSON Path Error while saving response to runtime variable.", e);
178184
}
179185
}
180186
if(jsonPathValidationsFailed){
181187
throw new AutomatorException(String.format(MSG_REST_RESPONSE_JSON_PATH_NOT_EXIST,failedJsonPathsList));
182188
}
189+
if(!StringUtils.isEmpty(exceptionStr)){
190+
throw new AutomatorException("Not able to find the json paths::"+exceptionStr);
191+
}
183192
}
184193

185194
}

0 commit comments

Comments
 (0)