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 82cf8f83c..04aa4c838 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 @@ -865,15 +865,16 @@ private MessageEvent doActionScrollTo(TestCaseExecution tCExecution, String elem MessageEvent message; try { + Offset offset = new Offset(offsets); Identifier identifier = identifierService.convertStringToIdentifierStrict(element); - LOG.debug("toto Identifier :'" + identifier.getIdentifier() + "' Locator '" + identifier.getLocator() + "'"); + LOG.debug("Identifier :'" + identifier.getIdentifier() + "' Locator '" + identifier.getLocator() + "'"); if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) { - return androidAppiumService.scrollTo(tCExecution.getSession(), identifier, maxScrollDown); + return androidAppiumService.scrollTo(tCExecution.getSession(), identifier, maxScrollDown, offset.getHOffset(), offset.getVOffset()); } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) { - return iosAppiumService.scrollTo(tCExecution.getSession(), identifier, maxScrollDown); + return iosAppiumService.scrollTo(tCExecution.getSession(), identifier, maxScrollDown, offset.getHOffset(), offset.getVOffset()); } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) { return webdriverService.scrollTo(tCExecution.getSession(), identifier, identifier.isSameIdentifier("") ? element : null, offsets); diff --git a/source/src/main/java/org/cerberus/core/service/appium/IAppiumService.java b/source/src/main/java/org/cerberus/core/service/appium/IAppiumService.java index 6e5b81aef..c3c8abeaf 100644 --- a/source/src/main/java/org/cerberus/core/service/appium/IAppiumService.java +++ b/source/src/main/java/org/cerberus/core/service/appium/IAppiumService.java @@ -112,7 +112,7 @@ public interface IAppiumService { * @return * @throws IllegalArgumentException */ - MessageEvent scrollTo(Session session, Identifier element, String numberScrollDownMax) throws IllegalArgumentException; + MessageEvent scrollTo(Session session, Identifier element, String numberScrollDownMax, Integer hOffset, Integer vOffset) throws IllegalArgumentException; /** * install an application on mobile devices diff --git a/source/src/main/java/org/cerberus/core/service/appium/impl/AppiumService.java b/source/src/main/java/org/cerberus/core/service/appium/impl/AppiumService.java index bd21949af..b9908639b 100644 --- a/source/src/main/java/org/cerberus/core/service/appium/impl/AppiumService.java +++ b/source/src/main/java/org/cerberus/core/service/appium/impl/AppiumService.java @@ -24,6 +24,8 @@ import io.appium.java_client.touch.WaitOptions; import io.appium.java_client.touch.offset.ElementOption; import io.appium.java_client.touch.offset.PointOption; +import lombok.Getter; +import lombok.Setter; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.cerberus.core.crud.service.impl.ParameterService; @@ -31,6 +33,7 @@ import org.cerberus.core.engine.entity.MessageEvent; import org.cerberus.core.engine.entity.MessageGeneral; import org.cerberus.core.engine.entity.Session; +import org.cerberus.core.engine.gwt.impl.ActionService; import org.cerberus.core.enums.MessageEventEnum; import org.cerberus.core.enums.MessageGeneralEnum; import org.cerberus.core.exception.CerberusEventException; @@ -379,7 +382,7 @@ public Direction getDirectionForSwipe(Session session, SwipeAction action) throw } @Override - public MessageEvent scrollTo(Session session, Identifier element, String numberScrollDownMax) throws IllegalArgumentException { + public MessageEvent scrollTo(Session session, Identifier element, String numberScrollDownMax, Integer hOffset, Integer vOffset) throws IllegalArgumentException { AppiumDriver driver = session.getAppiumDriver(); MessageEvent message; try { @@ -394,9 +397,9 @@ public MessageEvent scrollTo(Session session, Identifier element, String numberS // check text if (element.getIdentifier().equals("text")) { - scrollDown(driver, By.xpath("//*[contains(@text,'" + element.getLocator() + "')]"), numberOfScrollDown); + scrollDown(driver, By.xpath("//*[contains(@text,'" + element.getLocator() + "')]"), numberOfScrollDown, hOffset, vOffset); } else { - scrollDown(driver, this.getBy(element), numberOfScrollDown); + scrollDown(driver, this.getBy(element), numberOfScrollDown, hOffset, vOffset); } message.setDescription(message.getDescription().replace("%VALUE%", element.toString())); @@ -420,7 +423,7 @@ public MessageEvent scrollTo(Session session, Identifier element, String numberS * @param element * @return */ - private boolean scrollDown(AppiumDriver driver, By element, int numberOfScrollDown) throws CerberusEventException{ + private boolean scrollDown(AppiumDriver driver, By element, int numberOfScrollDown, Integer hOffset, Integer vOffset) throws CerberusEventException{ Dimension screenSize = driver.manage().window().getSize(); @@ -445,6 +448,11 @@ private boolean scrollDown(AppiumDriver driver, By element, int numberOfScrollDo do { boolean isPresent = driver.findElements(element).size() > 0; if (isPresent && driver.findElement(element).isDisplayed()) { + //Element found, perform another scroll to offset from middle of screen + int pressOffsetX = driver.manage().window().getSize().width / 2; + int pressOffsetY = driver.manage().window().getSize().height / 2; + scroll(driver, pressOffsetX, pressOffsetY, hOffset, vOffset); + return true; } else { scroll(driver, pressX, bottomY, pressX, topY); diff --git a/source/src/main/webapp/js/testcase/testcaseStatic.js b/source/src/main/webapp/js/testcase/testcaseStatic.js index 2c41c54a2..ceeff7b5e 100644 --- a/source/src/main/webapp/js/testcase/testcaseStatic.js +++ b/source/src/main/webapp/js/testcase/testcaseStatic.js @@ -138,7 +138,7 @@ var actionOptList = { "scrollTo":{"group":"mouse_action","value": "scrollTo","label":{"en":"Scroll to element","fr":"Scroller jusqu'à l'élément"},"application_types":["GUI","IPA","APK","FAT"], "field1":{"label":{"en": "Element path or Text to scroll to", "fr": "Chemin vers l'élement ou Texte à scroller"},"picto":"images/action-html.png", "class": "col-lg-12 crb-autocomplete-element crb-contextual-button"}, "field2":{"label":{"en": "Max scroll iteration [APK,IPA only]", "fr": "Nombre maximum de scroll vers le bas (8 par defaut) [seulement APK,IPA]"}, "class": "col-lg-12 crb-autocomplete-variable"}, - "field3":{"label":{"en": "offsets (h,v) [GUI only]", "fr": "offsets (h,v) [seulement GUI]"}, "class": "col-lg-6 crb-autocomplete-variable"},"documentation":{"en":"...","fr":"..."}}, + "field3":{"label":{"en": "offsets (h,v) [APK,IPA,GUI only]", "fr": "offsets (h,v) [seulement APK,IPA,GUI]"}, "class": "col-lg-6 crb-autocomplete-variable"},"documentation":{"en":"...","fr":"..."}}, "installApp":{"group":"access_application","value": "installApp","label":{"en":"Install Application","fr":"Installer l'Application"},"application_types":["IPA","APK"], "field1":{"label":{"en": "Application path (ex : /root/toto.apk)", "fr": "Chemin vers l'application (ex : /root/toto.apk)"},"picto":"images/action-mobile-application.png", "class": "col-lg-12 crb-autocomplete-variable"},"documentation":{"en":"...","fr":"..."}}, "removeApp":{"group":"access_application","value": "removeApp","label":{"en":"Uninstall Application","fr":"Désinstaller l'Application"},"application_types":["IPA","APK"],