Skip to content

Commit

Permalink
Merge origin/feature/selenium4 into feature/selenium4
Browse files Browse the repository at this point in the history
Conflicts:
	source/src/main/java/org/cerberus/core/engine/execution/impl/RobotServerService.java
	source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java
	source/src/main/resources/documentation/D2/include/en/changelog_4.20_en.adoc
  • Loading branch information
vertigo17 committed Feb 18, 2025
2 parents c0809f7 + 84700ab commit 3ac37b3
Show file tree
Hide file tree
Showing 73 changed files with 3,651 additions and 94 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/.idea/
*.mwb.beforefix
*.DS_Store
nb-configuration.xml

source/\.idea/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,45 +658,49 @@ && isNotAlreadyDefined(caps, "appWaitActivity"))) {
// Setting specific capabilities of external cloud providers.
switch (tCExecution.getRobotProvider()) {
case TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK:
if (!StringUtil.isEmptyOrNull(tCExecution.getTag()) && isNotAlreadyDefined(caps, "build")) {
cloudOptions.put("build", tCExecution.getTag());
Map<String, Object> browserstackOptions = new HashMap<>();
if (!StringUtil.isEmptyOrNull(tCExecution.getTag()) && isNotAlreadyDefined(caps, "buildName")) {
browserstackOptions.put("buildName", tCExecution.getTag());
}

if (isNotAlreadyDefined(caps, "project")) {
cloudOptions.put("project", tCExecution.getApplication());
if (isNotAlreadyDefined(caps, "projectName")) {
browserstackOptions.put("projectName", tCExecution.getApplication());
} else {
cloudOptions.put("project", caps.getCapability("project"));
browserstackOptions.put("projectName", caps.getCapability("projectName"));
}

if (isNotAlreadyDefined(caps, "name")) {
if (isNotAlreadyDefined(caps, "sessionName")) {
String externalExeName = parameterService.getParameterStringByKey("cerberus_browserstack_defaultexename", tCExecution.getSystem(), "Exe : %EXEID%");
externalExeName = externalExeName.replace("%EXEID%", String.valueOf(tCExecution.getId()));
externalExeName = externalExeName.replace("%TESTFOLDER%", String.valueOf(tCExecution.getTest()));
externalExeName = externalExeName.replace("%TESTID%", String.valueOf(tCExecution.getTestCase()));
externalExeName = externalExeName.replace("%TESTDESCRIPTION%", String.valueOf(tCExecution.getDescription()));
cloudOptions.put("name", externalExeName);
browserstackOptions.put("sessionName", externalExeName);
}

if (tCExecution.getVerbose() >= 2) {
if (isNotAlreadyDefined(caps, "browserstack.debug")) {
cloudOptions.put("browserstack.debug", true);
if (isNotAlreadyDefined(caps, "debug")) {
browserstackOptions.put("debug", true);
}
if (isNotAlreadyDefined(caps, "browserstack.console")) {
cloudOptions.put("browserstack.console", "warnings");
if (isNotAlreadyDefined(caps, "consoleLogs")) {
browserstackOptions.put("consoleLogs", "warnings");
}
if (isNotAlreadyDefined(caps, "browserstack.networkLogs")) {
cloudOptions.put("browserstack.networkLogs", true);
if (isNotAlreadyDefined(caps, "networkLogs")) {
browserstackOptions.put("networkLogs", true);
}
}

//Create or override these capabilities if proxy required.
if (StringUtil.parseBoolean(tCExecution.getRobotExecutorObj().getExecutorProxyType())) {
cloudOptions.put("browserstack.local", true);
cloudOptions.put("browserstack.user", tCExecution.getRobotExecutorObj().getHostUser());
cloudOptions.put("browserstack.key", tCExecution.getRobotExecutorObj().getHostPassword());
cloudOptions.put("browserstack.localIdentifier", tCExecution.getExecutionUUID());
browserstackOptions.put("local", true);
browserstackOptions.put("userName", tCExecution.getRobotExecutorObj().getHostUser());
browserstackOptions.put("accessKey", tCExecution.getRobotExecutorObj().getHostPassword());
browserstackOptions.put("localIdentifier", tCExecution.getExecutionUUID());
}

caps.setCapability("bstack:options", browserstackOptions);
break;

case TestCaseExecution.ROBOTPROVIDER_LAMBDATEST:
if (!StringUtil.isEmptyOrNull(tCExecution.getTag()) && isNotAlreadyDefined(caps, "build")) {
cloudOptions.put("build", tCExecution.getTag());
Expand All @@ -723,6 +727,7 @@ && isNotAlreadyDefined(caps, "appWaitActivity"))) {
cloudOptions.put("console", true);
}
}
caps.setCapability("cloud:options", cloudOptions);
break;
case TestCaseExecution.ROBOTPROVIDER_KOBITON:
if (isNotAlreadyDefined(caps, "sessionName")) {
Expand All @@ -749,12 +754,12 @@ && isNotAlreadyDefined(caps, "appWaitActivity"))) {
if (isNotAlreadyDefined(caps, "deviceGroup")) {
cloudOptions.put("deviceGroup", "KOBITON");
}
caps.setCapability("cloud:options", cloudOptions);
break;
case TestCaseExecution.ROBOTPROVIDER_NONE:
break;
default:
}
caps.setCapability("cloud:options", cloudOptions);
return caps;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public enum MessageEventEnum {
ACTION_SUCCESS_DOUBLECLICK(200, "OK", "Element '%ELEMENT%' double clicked.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
ACTION_SUCCESS_RIGHTCLICK(200, "OK", "Right click has been done on Element '%ELEMENT%'.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
ACTION_SUCCESS_URLLOGIN(200, "OK", "Opened '%URL%'.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
ACTION_SUCCESS_MOUSEOVER(200, "OK", "Mouse moved over '%ELEMENT%' with an offset %OFFSET%.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
ACTION_SUCCESS_MOUSEOVER(200, "OK", "Mouse moved over '%ELEMENT%' with an offset '%OFFSET%'.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
ACTION_SUCCESS_MOUSEMOVE(200, "OK", "Mouse moved with coord '%COORD%'.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
ACTION_SUCCESS_WAIT_TIME(200, "OK", "Waited %TIME% ms.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
ACTION_SUCCESS_WAIT_TIME_WITHWARNINGS(200, "OK", "Waited %TIME% ms with warning : %MESSAGE%", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
ACTION_SUCCESS_WAIT_ELEMENT(200, "OK", "Waited for %ELEMENT%.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
Expand Down Expand Up @@ -287,6 +288,8 @@ public enum MessageEventEnum {
ACTION_FAILED_DOUBLECLICK_NO_SUCH_ELEMENT(268, "FA", "Failed to double click because could not find element '%ELEMENT%'!", true, true, true, MessageGeneralEnum.EXECUTION_FA_ACTION),
ACTION_FAILED_TYPE_NO_SUCH_ELEMENT(269, "FA", "Failed to type because could not find element '%ELEMENT%'!", true, true, true, MessageGeneralEnum.EXECUTION_FA_ACTION),
ACTION_FAILED_MOUSEOVER_NO_SUCH_ELEMENT(270, "FA", "Failed to move mouse over because could not find element '%ELEMENT%'!", true, true, true, MessageGeneralEnum.EXECUTION_FA_ACTION),
ACTION_FAILED_MOUSEOVER_OFFSETFORMAT(270, "FA", "Failed to move mouse over with offset because offset '%OFFSET%' does not respect the correct format xoffset,yoffset (ex: -50,50)!", true, true, true, MessageGeneralEnum.EXECUTION_FA_ACTION),
ACTION_FAILED_MOUSEMOVE(270, "FA", "Failed to move mouse with coord '%COORD%' because '%ERROR%'!", true, true, true, MessageGeneralEnum.EXECUTION_FA_ACTION),
ACTION_FAILED_WAIT_NO_SUCH_ELEMENT(271, "FA", "Failed to wait because could not find element '%ELEMENT%'!", true, true, true, MessageGeneralEnum.EXECUTION_FA_ACTION),
ACTION_FAILED_WAIT_ERRATUM_MISSING_SEPARATOR(271, "FA", "Failed to wait because syntax error on erratum value (separator '%SEPARATOR%' is missing) !", true, true, true, MessageGeneralEnum.EXECUTION_FA_ACTION),
ACTION_FAILED_WAIT_ERRATUM_ELEMENT_NOT_FOUND(271, "FA", "Failed to wait because Erratum could not match the element on new page ! That can happen if page is too different from the original one.", true, true, true, MessageGeneralEnum.EXECUTION_FA_ACTION),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* Cerberus Copyright (C) 2013 - 2025 cerberustesting
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This file is part of Cerberus.
*
*
* Cerberus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* Cerberus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with Cerberus. If not, see <http://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -100,7 +100,7 @@ public class SikuliService implements ISikuliService {
private static final String SIKULI_EXECUTEACTION_PATH = "/extra/ExecuteSikuliAction";

private JSONObject generatePostParameters(String action, String locator, String locator2, String text, String text2,
long defaultWait, String minSimilarity, Integer highlightElement, String typeDelay) throws JSONException, IOException, MalformedURLException, MimeTypeException {
long defaultWait, String minSimilarity, Integer highlightElement, String typeDelay) throws JSONException, IOException, MalformedURLException, MimeTypeException {
JSONObject result = new JSONObject();
String picture = "";
String extension = "";
Expand Down Expand Up @@ -364,7 +364,7 @@ public AnswerItem<JSONObject> doSikuliAction(Session session, String action, Str

// Send post request
os = new PrintStream(connection.getOutputStream());
LOG.debug("Sending JSON : {}", postParameters.toString());
LOG.debug("Sending JSON : {}", postParameters.toString(1));
os.println(postParameters.toString());
// os.println("|ENDS|");

Expand Down Expand Up @@ -593,7 +593,28 @@ public MessageEvent doSikuliActionLeftButtonRelease(Session session) {

@Override
public MessageEvent doSikuliActionMouseMove(Session session, String xyoffset) {
AnswerItem<JSONObject> actionResult = doSikuliAction(session, this.SIKULI_MOUSEMOVE, null, null, xyoffset, "");
AnswerItem<JSONObject> actionResult = null;

if (StringUtil.isNotEmptyOrNull(xyoffset)) {
actionResult = doSikuliAction(session, this.SIKULI_MOUSEMOVE, null, null, xyoffset, "");
} else {
MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_MOUSEMOVE);
message.resolveDescription("%COORD%", "0,0");
return message;
}

if (actionResult == null || actionResult.getResultMessage().getCodeString().equals(new MessageEvent(MessageEventEnum.ACTION_SUCCESS).getCodeString())) {
MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_MOUSEMOVE);
message.resolveDescription("COORD", xyoffset);
return message;
}
if (actionResult.getResultMessage().getCodeString().equals(new MessageEvent(MessageEventEnum.ACTION_FAILED).getCodeString())) {
MessageEvent mes = new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEMOVE);
mes.resolveDescription("ERROR", actionResult.getMessageDescription());
mes.resolveDescription("COORD", xyoffset);
return mes;
}

return actionResult.getResultMessage();

}
Expand Down Expand Up @@ -652,24 +673,39 @@ public MessageEvent doSikuliActionType(Session session, String locator, String t
public MessageEvent doSikuliActionMouseOver(Session session, String locator, String text, String offset) {
AnswerItem<JSONObject> actionResult = null;

// We check here that offxet format is correct and report an error if invalid.
if (StringUtil.isNotEmptyOrNull(offset)) {
try {
Integer[] offsetInt = StringUtil.getxFromOffset(offset);
} catch (Exception e) {
MessageEvent mes = new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEOVER_OFFSETFORMAT);
mes.setDescription(mes.getDescription().replace("%OFFSET%", offset));
return mes;
}
}

if (!locator.isEmpty()) {
actionResult = doSikuliAction(session, this.SIKULI_MOUSEOVER, locator, null, "", "");
actionResult = doSikuliAction(session, this.SIKULI_MOUSEMOVE, null, null, offset, "");
if (StringUtil.isNotEmptyOrNull(offset)) {
actionResult = doSikuliAction(session, this.SIKULI_MOUSEMOVE, null, null, offset, "");
}
} else {
actionResult = doSikuliAction(session, this.SIKULI_MOUSEOVER, null, null, text, "");
actionResult = doSikuliAction(session, this.SIKULI_MOUSEMOVE, null, null, offset, "");
if (StringUtil.isNotEmptyOrNull(offset)) {
actionResult = doSikuliAction(session, this.SIKULI_MOUSEMOVE, null, null, offset, "");
}
}

if (actionResult.getResultMessage().getCodeString().equals(new MessageEvent(MessageEventEnum.ACTION_SUCCESS).getCodeString())) {
MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_MOUSEOVER);
message.setDescription(message.getDescription().replace("%ELEMENT%", locator));
message.setDescription(message.getDescription().replace("%OFFSET%", "("+offset+")"));
message.setDescription(message.getDescription().replace("%OFFSET%", offset));
return message;
}
if (actionResult.getResultMessage().getCodeString().equals(new MessageEvent(MessageEventEnum.ACTION_FAILED).getCodeString())) {
MessageEvent mes = new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEOVER_NO_SUCH_ELEMENT);
mes.setDescription(mes.getDescription().replace("%ELEMENT%", locator) + " - " + actionResult.getMessageDescription());
mes.setDescription(mes.getDescription().replace("%OFFSET%", "("+offset+")"));
mes.setDescription(mes.getDescription().replace("%OFFSET%", offset));
return mes;
}

Expand Down
19 changes: 19 additions & 0 deletions source/src/main/java/org/cerberus/core/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,25 @@ public static String getLeftString(String string1, int length) {
}
}

/**
* Return x part of offset.
*
* @param offset
* @return the {length} first character of the string1.
*/
public static Integer[] getxFromOffset(String offset) throws NumberFormatException {
Integer[] res = new Integer[2];
if (offset.contains(",")) {
String x = offset.split(",")[0];
res[0] = Integer.valueOf(x);
String y = offset.split(",")[1];
res[1] = Integer.valueOf(y);
return res;
} else {
throw new NumberFormatException();
}
}

/**
* Return left part of the string adding ... at the end.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

*Warning to be considered before applying the version (deprecated features)*
[square]
* none
* none
2 changes: 1 addition & 1 deletion source/src/main/resources/log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ appender.console.layout.pattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
#logger.file.level = debug
#logger.file.appenderRefs = file
#logger.file.appenderRef.file.ref = LOGFILE
rootLogger.level=info
rootLogger.level=debug
rootLogger.appenderRefs=stdout
rootLogger.appenderRef.stdout.ref=STDOUT
2 changes: 1 addition & 1 deletion source/src/main/webapp/META-INF/context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
-->
<Context path="/Cerberus">
<!-- <Valve className="org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve"/> -->
<Valve className="org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve"/>
</Context>
1 change: 1 addition & 0 deletions source/src/main/webapp/TestCaseScript.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<script type="text/javascript" src="dependencies/Tinymce-6.7.0/tinymce.min.js"></script>
<script type="text/javascript" src="dependencies/Bootstrap-treeview-1.2.0/js/bootstrap-treeview.js"></script>
<script type="text/javascript" src="dependencies/Ace-1.2.6/ext-language_tools.js"></script>
<!-- <script type="text/javascript" src="dependencies/Ace-1.38.0/ext-language_tools.js"></script>-->
<script type="text/javascript" src="js/pages/TestCaseScript.js"></script>
<script type="text/javascript" src="js/transversalobject/TestCase.js"></script>
<script type="text/javascript" src="js/transversalobject/ApplicationObject.js"></script>
Expand Down
23 changes: 23 additions & 0 deletions source/src/main/webapp/dependencies/Ace-1.38.0/ace.js

Large diffs are not rendered by default.

Loading

0 comments on commit 3ac37b3

Please sign in to comment.