diff --git a/README.md b/README.md index 71a2816..2e94dcc 100644 --- a/README.md +++ b/README.md @@ -298,7 +298,17 @@ element.getAttribute("attribute")
-element.scrollIntoView()
+element.scrollTo()
+
+ +
+element.scrollUp()
+
+ +Note: For the web version, both scrollUp() and scrollDown() use the same Selenide method. + +
+element.scrollDown()
 
diff --git a/src/main/java/testUI/elements/Element.java b/src/main/java/testUI/elements/Element.java
index 7af6aaf..93ba4e6 100644
--- a/src/main/java/testUI/elements/Element.java
+++ b/src/main/java/testUI/elements/Element.java
@@ -583,6 +583,74 @@ public UIElement swipe(int XCoordinate, int YCoordinate) {
         return getElementObject();
     }
 
+    public UIElement scrollUp() {
+        try {
+            if (!Configuration.automationType.equals(Configuration.DESKTOP_PLATFORM)) {
+                WebElement slider = getElement(
+                        accesibilityIdiOS,
+                        accesibilityId,
+                        iOSElement,
+                        element,
+                        index,
+                        collection);
+                Dimension size = getDriver().manage().window().getSize();
+                int endY = (int) (size.height * 0.2);
+                Point source = slider.getLocation();
+                PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
+                Sequence sequence = new Sequence(finger, 1);
+                sequence.addAction(finger.createPointerMove(Duration.ofMillis(0),
+                        PointerInput.Origin.viewport(), source.x, source.y));
+                sequence.addAction(finger.createPointerDown(PointerInput.MouseButton.MIDDLE.asArg()));
+                sequence.addAction(new Pause(finger, Duration.ofMillis(600)));
+                sequence.addAction(finger.createPointerMove(Duration.ofMillis(600),
+                        PointerInput.Origin.viewport(), source.x, source.y - endY));
+                sequence.addAction(finger.createPointerUp(PointerInput.MouseButton.MIDDLE.asArg()));
+
+                getDriver().perform(singletonList(sequence));
+            } else {
+                getSelenide(SelenideElement, index, collection).scrollIntoView(true);
+            }
+        } catch (Throwable e) {
+            takeScreenshotsAllure();
+            TestUIException.handleError(e.getMessage());
+        }
+        return getElementObject();
+    }
+
+    public UIElement scrollDown() {
+        try {
+            if (!Configuration.automationType.equals(Configuration.DESKTOP_PLATFORM)) {
+                WebElement slider = getElement(
+                        accesibilityIdiOS,
+                        accesibilityId,
+                        iOSElement,
+                        element,
+                        index,
+                        collection);
+                Dimension size = getDriver().manage().window().getSize();
+                int endY = (int) (size.height * 0.8);
+                Point source = slider.getLocation();
+                PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
+                Sequence sequence = new Sequence(finger, 1);
+                sequence.addAction(finger.createPointerMove(Duration.ofMillis(0),
+                        PointerInput.Origin.viewport(), source.x, source.y));
+                sequence.addAction(finger.createPointerDown(PointerInput.MouseButton.MIDDLE.asArg()));
+                sequence.addAction(new Pause(finger, Duration.ofMillis(600)));
+                sequence.addAction(finger.createPointerMove(Duration.ofMillis(600),
+                        PointerInput.Origin.viewport(), source.x, source.y + endY));
+                sequence.addAction(finger.createPointerUp(PointerInput.MouseButton.MIDDLE.asArg()));
+
+                getDriver().perform(singletonList(sequence));
+            } else {
+                getSelenide(SelenideElement, index, collection).scrollIntoView(true);
+            }
+        } catch (Throwable e) {
+            takeScreenshotsAllure();
+            TestUIException.handleError(e.getMessage());
+        }
+        return getElementObject();
+    }
+
     public UIElement swipeRight() {
         try {
             if (!Configuration.automationType.equals(Configuration.DESKTOP_PLATFORM)) {
diff --git a/src/main/java/testUI/elements/UIElement.java b/src/main/java/testUI/elements/UIElement.java
index 00f7697..2302786 100644
--- a/src/main/java/testUI/elements/UIElement.java
+++ b/src/main/java/testUI/elements/UIElement.java
@@ -58,6 +58,10 @@ public interface UIElement {
 
     SlideActions scrollTo();
 
+    UIElement scrollUp();
+
+    UIElement scrollDown();
+
     UIElement swipe(int XCoordinate, int YCoordinate);
 
     UIElement swipeRight();