Skip to content

Commit f8ef9c1

Browse files
fix: Scroll issue in flutter integration driver (#2227)
1 parent b96c868 commit f8ef9c1

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

src/e2eFlutterTest/java/io/appium/java_client/android/CommandTest.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
import org.openqa.selenium.WebElement;
1313

1414
import java.io.IOException;
15+
import java.time.Duration;
1516

17+
import static java.lang.Boolean.parseBoolean;
1618
import static org.junit.jupiter.api.Assertions.assertEquals;
1719
import static org.junit.jupiter.api.Assertions.assertFalse;
1820
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -52,18 +54,37 @@ void testScrollTillVisibleCommand() {
5254
openScreen("Vertical Swiping");
5355

5456
WebElement firstElement = driver.scrollTillVisible(new ScrollParameter(AppiumBy.flutterText("Java")));
55-
assertTrue(Boolean.parseBoolean(firstElement.getAttribute("displayed")));
57+
assertTrue(parseBoolean(firstElement.getAttribute("displayed")));
5658

5759
WebElement lastElement = driver.scrollTillVisible(new ScrollParameter(AppiumBy.flutterText("Protractor")));
58-
assertTrue(Boolean.parseBoolean(lastElement.getAttribute("displayed")));
59-
assertFalse(Boolean.parseBoolean(firstElement.getAttribute("displayed")));
60+
assertTrue(parseBoolean(lastElement.getAttribute("displayed")));
61+
assertFalse(parseBoolean(firstElement.getAttribute("displayed")));
6062

6163
firstElement = driver.scrollTillVisible(
6264
new ScrollParameter(AppiumBy.flutterText("Java"),
6365
ScrollParameter.ScrollDirection.UP)
6466
);
65-
assertTrue(Boolean.parseBoolean(firstElement.getAttribute("displayed")));
66-
assertFalse(Boolean.parseBoolean(lastElement.getAttribute("displayed")));
67+
assertTrue(parseBoolean(firstElement.getAttribute("displayed")));
68+
assertFalse(parseBoolean(lastElement.getAttribute("displayed")));
69+
}
70+
71+
@Test
72+
void testScrollTillVisibleWithScrollParametersCommand() {
73+
WebElement loginButton = driver.findElement(BaseFlutterTest.LOGIN_BUTTON);
74+
loginButton.click();
75+
openScreen("Vertical Swiping");
76+
77+
ScrollParameter scrollParameter = new ScrollParameter(AppiumBy.flutterText("Playwright"));
78+
scrollParameter
79+
.setScrollView(AppiumBy.flutterType("Scrollable"))
80+
.setMaxScrolls(30)
81+
.setDelta(30)
82+
// Drag duration currently works when the value is greater than 33 secs
83+
.setDragDuration(Duration.ofMillis(35000))
84+
.setSettleBetweenScrollsTimeout(5000);
85+
86+
WebElement element = driver.scrollTillVisible(scrollParameter);
87+
assertTrue(parseBoolean(element.getAttribute("displayed")));
6788
}
6889

6990
@Test

src/main/java/io/appium/java_client/flutter/commands/ScrollParameter.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import lombok.Getter;
55
import lombok.Setter;
66
import lombok.experimental.Accessors;
7-
import org.openqa.selenium.WebElement;
87
import org.openqa.selenium.internal.Require;
98

109
import java.time.Duration;
@@ -18,7 +17,7 @@
1817
@Setter
1918
public class ScrollParameter extends FlutterCommandParameter {
2019
private AppiumBy.FlutterBy scrollTo;
21-
private WebElement scrollView;
20+
private AppiumBy.FlutterBy scrollView;
2221
private ScrollDirection scrollDirection;
2322
private Integer delta;
2423
private Integer maxScrolls;
@@ -56,13 +55,13 @@ public Map<String, Object> toJson() {
5655

5756
params.put("finder", parseFlutterLocator(scrollTo));
5857
Optional.ofNullable(scrollView)
59-
.ifPresent(scrollView -> params.put("scrollView", scrollView));
58+
.ifPresent(scrollView -> params.put("scrollView", parseFlutterLocator(scrollView)));
6059
Optional.ofNullable(delta)
6160
.ifPresent(delta -> params.put("delta", delta));
6261
Optional.ofNullable(maxScrolls)
63-
.ifPresent(maxScrolls -> params.put("delta", maxScrolls));
62+
.ifPresent(maxScrolls -> params.put("maxScrolls", maxScrolls));
6463
Optional.ofNullable(settleBetweenScrollsTimeout)
65-
.ifPresent(timeout -> params.put("delta", settleBetweenScrollsTimeout));
64+
.ifPresent(timeout -> params.put("settleBetweenScrollsTimeout", settleBetweenScrollsTimeout));
6665
Optional.ofNullable(scrollDirection)
6766
.ifPresent(direction -> params.put("scrollDirection", direction.getDirection()));
6867
Optional.ofNullable(dragDuration)

0 commit comments

Comments
 (0)