diff --git a/source/src/main/java/org/cerberus/core/crud/entity/TestCaseStepAction.java b/source/src/main/java/org/cerberus/core/crud/entity/TestCaseStepAction.java index 83391d17c..5a571c970 100644 --- a/source/src/main/java/org/cerberus/core/crud/entity/TestCaseStepAction.java +++ b/source/src/main/java/org/cerberus/core/crud/entity/TestCaseStepAction.java @@ -145,10 +145,6 @@ public class TestCaseStepAction { // ??? TODO. Clean this unused action. public static final String ACTION_PERFORMEDITORACTION = "performEditorAction"; - // DEPRECATED - public static final String ACTION_REMOVEDIFFERENCE = "removeDifference"; - public static final String ACTION_MOUSEOVERANDWAIT = "mouseOverAndWait"; - /** * Invariant FORCEEXESTATUS String. */ diff --git a/source/src/main/java/org/cerberus/core/engine/gwt/impl/ActionService.java b/source/src/main/java/org/cerberus/core/engine/gwt/impl/ActionService.java index fa9521c34..751480073 100644 --- a/source/src/main/java/org/cerberus/core/engine/gwt/impl/ActionService.java +++ b/source/src/main/java/org/cerberus/core/engine/gwt/impl/ActionService.java @@ -482,21 +482,6 @@ public TestCaseStepActionExecution doAction(TestCaseStepActionExecution actionEx case TestCaseStepAction.ACTION_DONOTHING: res = new MessageEvent(MessageEventEnum.ACTION_SUCCESS); break; - /** - * DEPRECATED ACTIONS FROM HERE. - */ - case TestCaseStepAction.ACTION_MOUSEOVERANDWAIT: - res = this.doActionMouseOverAndWait(execution, value1, value2); - res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription()); - logEventService.createForPrivateCalls("ENGINE", "mouseOverAndWait", LogEvent.STATUS_WARN, MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + actionExecution.getTest() + "|" + actionExecution.getTestCase() + "']"); - LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action mouseOverAndWait triggered by TestCase : ['" + actionExecution.getTest() + "'|'" + actionExecution.getTestCase() + "']"); - break; - case TestCaseStepAction.ACTION_REMOVEDIFFERENCE: - res = this.doActionRemoveDifference(actionExecution, value1, value2); - res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription()); - logEventService.createForPrivateCalls("ENGINE", "removeDifference", LogEvent.STATUS_WARN, MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + actionExecution.getTest() + "|" + actionExecution.getTestCase() + "']"); - LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action removeDifference triggered by TestCase : ['" + actionExecution.getTest() + "'|'" + actionExecution.getTestCase() + "']"); - break; default: res = new MessageEvent(MessageEventEnum.ACTION_FAILED_UNKNOWNACTION); res.setDescription(res.getDescription().replace("%ACTION%", actionExecution.getAction())); @@ -590,7 +575,6 @@ private TestCaseStepActionExecution cleanValues(TestCaseStepActionExecution acti case TestCaseStepAction.ACTION_MOUSELEFTBUTTONRELEASE: case TestCaseStepAction.ACTION_DOUBLECLICK: case TestCaseStepAction.ACTION_RIGHTCLICK: - case TestCaseStepAction.ACTION_MOUSEOVER: case TestCaseStepAction.ACTION_MOUSEMOVE: case TestCaseStepAction.ACTION_OPENURLWITHBASE: case TestCaseStepAction.ACTION_FOCUSTOIFRAME: @@ -636,6 +620,7 @@ private TestCaseStepActionExecution cleanValues(TestCaseStepActionExecution acti case TestCaseStepAction.ACTION_GETROBOTFILE: case TestCaseStepAction.ACTION_SCROLLTO: case TestCaseStepAction.ACTION_UPLOADROBOTFILE: + case TestCaseStepAction.ACTION_MOUSEOVER: break; default: @@ -1370,15 +1355,25 @@ private MessageEvent doActionType(TestCaseExecution tCExecution, String value1, } } - private MessageEvent doActionMouseOver(TestCaseExecution tCExecution, String object, String property) { + private MessageEvent doActionMouseOver(TestCaseExecution tCExecution, String element, String offset) { MessageEvent message; - String element; try { /** - * Get element to use String object if not empty, String property if - * object empty, throws Exception if both empty) + * Check offset format */ - element = getElementToUse(object, property, "mouseOver", tCExecution); + Integer hOffset = 0; + Integer vOffset = 0; + + try { + if (!StringUtil.isEmptyOrNull(offset)) { + String[] soffsets = offset.split(","); + hOffset = Integer.valueOf(soffsets[0]); + vOffset = Integer.valueOf(soffsets[1]); + } + } catch (Exception ex){ + LOG.warn("Error decoding offset. It must be in two integers splited by comma. Continue with 0,0. Details :" +ex); + } + /** * Get Identifier (identifier, locator) */ @@ -1387,23 +1382,23 @@ private MessageEvent doActionMouseOver(TestCaseExecution tCExecution, String obj if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) { if (tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.ANDROID.toString())) { identifierService.checkWebElementIdentifier(identifier.getIdentifier()); - return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier, false, false); + return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier, hOffset, vOffset, false, false); } else { if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) { - return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), ""); + return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "", offset); } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) { - return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator()); + return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator(), offset); } else { identifierService.checkWebElementIdentifier(identifier.getIdentifier()); - return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier, true, true); + return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier, hOffset, vOffset, true, true); } } } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) { identifierService.checkSikuliIdentifier(identifier.getIdentifier()); if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) { - return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), ""); + return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "", offset); } else { - return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator()); + return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator(), offset); } } @@ -1417,44 +1412,6 @@ private MessageEvent doActionMouseOver(TestCaseExecution tCExecution, String obj } } - private MessageEvent doActionMouseOverAndWait(TestCaseExecution tCExecution, String object, String property) { - MessageEvent message; - try { - /** - * Check object is not null - */ - if (object == null) { - return new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEOVERANDWAIT_GENERIC); - } - /** - * Get Identifier (identifier, locator) - */ - Identifier identifier = identifierService.convertStringToIdentifier(object); - identifierService.checkWebElementIdentifier(identifier.getIdentifier()); - - if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) { - if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) { - message = sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), ""); - } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) { - message = sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator()); - } else { - message = webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier, true, true); - } - if (message.getCodeString().equals("OK")) { - message = this.doActionWait(tCExecution, property, null); - } - return message; - } - message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION); - message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_MOUSEOVERANDWAIT)); - message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType())); - return message; - } catch (CerberusEventException ex) { - LOG.fatal("Error doing Action MouseOverAndWait :" + ex); - return ex.getMessageError(); - } - } - private MessageEvent doActionWait(TestCaseExecution tCExecution, String value1, String value2) { MessageEvent message; String element; @@ -1881,33 +1838,6 @@ private MessageEvent doActionCallService(TestCaseStepActionExecution action, Str } - private MessageEvent doActionRemoveDifference(TestCaseStepActionExecution testCaseStepActionExecution, String object, String property) { - // Filters differences from the given object pattern - String filteredDifferences = xmlUnitService.removeDifference(object, property); - - // If filtered differences are null then service has returned with errors - if (filteredDifferences == null) { - MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_REMOVEDIFFERENCE); - message.setDescription(message.getDescription().replace("%DIFFERENCE%", object)); - message.setDescription(message.getDescription().replace("%DIFFERENCES%", property)); - return message; - } - - // Sets the property value to the new filtered one - for (TestCaseExecutionData data : testCaseStepActionExecution.getTestCaseExecutionDataList()) { - if (data.getProperty().equals(testCaseStepActionExecution.getPropertyName())) { - data.setValue(filteredDifferences); - break; - } - } - - // Sends success - MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_REMOVEDIFFERENCE); - message.setDescription(message.getDescription().replace("%DIFFERENCE%", object)); - message.setDescription(message.getDescription().replace("%DIFFERENCES%", property)); - return message; - } - private MessageEvent doActionCalculateProperty(TestCaseStepActionExecution testCaseStepActionExecution, String value1, String value2) { MessageEvent message; AnswerItem answerDecode = new AnswerItem<>(); diff --git a/source/src/main/java/org/cerberus/core/enums/MessageEventEnum.java b/source/src/main/java/org/cerberus/core/enums/MessageEventEnum.java index 88cf08d4a..6f86cf493 100644 --- a/source/src/main/java/org/cerberus/core/enums/MessageEventEnum.java +++ b/source/src/main/java/org/cerberus/core/enums/MessageEventEnum.java @@ -189,7 +189,7 @@ 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%'.", 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_MOUSEOVERANDWAIT(200, "OK", "Mouse moved over '%ELEMENT%' and waited %TIME% ms.", 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), diff --git a/source/src/main/java/org/cerberus/core/service/robotextension/ISikuliService.java b/source/src/main/java/org/cerberus/core/service/robotextension/ISikuliService.java index 716393d7e..b99ea904f 100644 --- a/source/src/main/java/org/cerberus/core/service/robotextension/ISikuliService.java +++ b/source/src/main/java/org/cerberus/core/service/robotextension/ISikuliService.java @@ -162,7 +162,7 @@ public interface ISikuliService { * @param text * @return */ - public MessageEvent doSikuliActionMouseOver(Session session, String locator, String text); + public MessageEvent doSikuliActionMouseOver(Session session, String locator, String text, String offset); /** * diff --git a/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java b/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java index fcde18484..3e8b8b5cb 100644 --- a/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java +++ b/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java @@ -644,23 +644,27 @@ public MessageEvent doSikuliActionType(Session session, String locator, String t } @Override - public MessageEvent doSikuliActionMouseOver(Session session, String locator, String text) { + public MessageEvent doSikuliActionMouseOver(Session session, String locator, String text, String offset) { AnswerItem actionResult = null; if (!locator.isEmpty()) { actionResult = doSikuliAction(session, this.SIKULI_MOUSEOVER, locator, null, "", ""); + 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 (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+")")); 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+")")); return mes; } diff --git a/source/src/main/java/org/cerberus/core/service/webdriver/IWebDriverService.java b/source/src/main/java/org/cerberus/core/service/webdriver/IWebDriverService.java index f644f7f2b..a4d4e0ff6 100644 --- a/source/src/main/java/org/cerberus/core/service/webdriver/IWebDriverService.java +++ b/source/src/main/java/org/cerberus/core/service/webdriver/IWebDriverService.java @@ -127,7 +127,7 @@ public interface IWebDriverService { MessageEvent doSeleniumActionType(Session session, Identifier identifier, String valueToType, String propertyName, boolean waitForVisibility, boolean waitForClickability); - MessageEvent doSeleniumActionMouseOver(Session session, Identifier identifier, boolean waitForVisibility, boolean waitForClickability); + MessageEvent doSeleniumActionMouseOver(Session session, Identifier identifier, Integer hOffset, Integer vOffset, boolean waitForVisibility, boolean waitForClickability); MessageEvent doSeleniumActionWait(Session session, Identifier identifier); diff --git a/source/src/main/java/org/cerberus/core/service/webdriver/impl/WebDriverService.java b/source/src/main/java/org/cerberus/core/service/webdriver/impl/WebDriverService.java index e4355238d..524bfe785 100644 --- a/source/src/main/java/org/cerberus/core/service/webdriver/impl/WebDriverService.java +++ b/source/src/main/java/org/cerberus/core/service/webdriver/impl/WebDriverService.java @@ -1276,7 +1276,7 @@ public MessageEvent doSeleniumActionType(Session session, Identifier identifier, } @Override - public MessageEvent doSeleniumActionMouseOver(Session session, Identifier identifier, boolean waitForVisibility, boolean waitForClickability) { + public MessageEvent doSeleniumActionMouseOver(Session session, Identifier identifier, Integer hOffset, Integer vOffset, boolean waitForVisibility, boolean waitForClickability) { MessageEvent message; try { AnswerItem answer = this.getSeleniumElement(session, identifier, waitForVisibility, waitForClickability); @@ -1284,10 +1284,11 @@ public MessageEvent doSeleniumActionMouseOver(Session session, Identifier identi WebElement menuHoverLink = (WebElement) answer.getItem(); if (menuHoverLink != null) { Actions actions = new Actions(session.getDriver()); - actions.moveToElement(menuHoverLink); + actions.moveToElement(menuHoverLink, hOffset, vOffset); actions.build().perform(); message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_MOUSEOVER); message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator())); + message.setDescription(message.getDescription().replace("%OFFSET%", "("+hOffset+","+vOffset+")")); return message; } } @@ -1296,6 +1297,7 @@ public MessageEvent doSeleniumActionMouseOver(Session session, Identifier identi } catch (NoSuchElementException exception) { message = new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEOVER_NO_SUCH_ELEMENT); message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator())); + message.setDescription(message.getDescription().replace("%OFFSET%", "("+hOffset+","+vOffset+")")); LOG.debug(exception.toString()); return message; } catch (TimeoutException exception) { diff --git a/source/src/main/webapp/js/testcase/testcaseStatic.js b/source/src/main/webapp/js/testcase/testcaseStatic.js index 9e00310ab..6c01f6fdd 100644 --- a/source/src/main/webapp/js/testcase/testcaseStatic.js +++ b/source/src/main/webapp/js/testcase/testcaseStatic.js @@ -49,7 +49,8 @@ var actionOptList = { "rightClick":{"group":"mouse_action", "value": "rightClick", "label":{"en":"Right Click","fr":"Clic droit"}, "application_types":["GUI","FAT"], "field1":{"label":{"en": "Element path", "fr": "Chemin vers l'élement à clicker avec le bouton droit"},"picto":"images/action-html.png", "class": "col-lg-12 crb-autocomplete-element crb-contextual-button"}}, "mouseOver":{"group":"mouse_action", "value": "mouseOver", "label":{"en":"Mouse Over","fr":"Souris sur l'élément"}, "application_types":["GUI","FAT"], - "field1":{"label":{"en": "Element path", "fr": "Chemin vers l'élement"},"picto":"images/action-html.png", "class": "col-lg-12 crb-autocomplete-element crb-contextual-button"}}, + "field1":{"label":{"en": "Element path", "fr": "Chemin vers l'élement"},"picto":"images/action-html.png", "class": "col-lg-12 crb-autocomplete-element crb-contextual-button"}, + "field2":{"label":{"en": "[Optional] Relative coord. (ex : 50,100)", "fr": "[Optionnel] Coordonnées relatives (ex : 50,100)"},"picto":"images/action-numeric.png", "class": "col-lg-12 crb-autocomplete-element crb-contextual-button"}}, "mouseMove":{"group":"mouse_action", "value": "mouseMove", "label":{"en":"Move Mouse","fr":"Déplacer la souris"}, "application_types":["GUI","FAT"], "field1":{"label":{"en": "Relative coord. (ex : 50,100 ; 200,50)", "fr": "Coordonnées relatives (ex : 50,100 ; 200,50)"}, "class": "col-lg-12 crb-autocomplete-element crb-contextual-button"}}, "openUrlWithBase":{"group":"access_application","value": "openUrlWithBase","label":{"en":"openUrlWithBase","fr":"Appeler l'URI"},"application_types":["GUI","IPA","APK"],