Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,17 @@ element.getAttribute("attribute")
</pre>

<pre>
element.scrollIntoView()
element.scrollTo()
</pre>

<pre>
element.scrollUp()
</pre>

Note: For the web version, both scrollUp() and scrollDown() use the same Selenide method.

<pre>
element.scrollDown()
</pre>

<pre>
Expand Down
68 changes: 68 additions & 0 deletions src/main/java/testUI/elements/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/testUI/elements/UIElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public interface UIElement {

SlideActions scrollTo();

UIElement scrollUp();

UIElement scrollDown();

UIElement swipe(int XCoordinate, int YCoordinate);

UIElement swipeRight();
Expand Down