Open dlewis2017 opened 1 year ago
Is there an alternative I can use in the meantime or an alternative approach to scroll/drag? driver.execute_scrip("mobile:scroll", scroll_args)
doesn't seem to be working either
I'm scrolling like this in Java:
import org.openqa.selenium.interactions.PointerInput;
import org.openqa.selenium.interactions.Sequence;
...
public static void scrollByCoordinates(int xStart, int yStart, int xEnd, int yEnd) {
switchContext("NATIVE_APP");
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence dragNDrop = new Sequence(finger, 1);
dragNDrop.addAction(finger.createPointerMove(Duration.ofMillis(0),
PointerInput.Origin.viewport(), xStart, yStart));
dragNDrop.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
dragNDrop.addAction(finger.createPointerMove(Duration.ofMillis(200),
PointerInput.Origin.viewport(), xEnd, yEnd));
dragNDrop.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
getAppiumInstance().getDriver().perform(List.of(dragNDrop));
switchContext("FLUTTER");
waitMilliseconds(100);
}
Other languages here https://appium.readthedocs.io/en/latest/en/commands/interactions/actions/
So I managed to get it working but only scrollIntoView and somewhat scrolluntilVisible. The issue was syntax. I had to use:
driver.execute_script("flutter:scrollIntoView", locator, {"alignment": 0})
. Also, it seems you HAVE to have the map with alignment defined and set. It didn't seem to work without it which is an issue.
I also tried to use scrollUntilTapable
seemed to scroll the wrong ListView even if the correct key was provided. It was also scroll indefinitely.
scrollUntilVisible
I managed to get working and has similar issues as scrollUntilTapable
UNLESS you specify a waitTimeoutMilliseconds
property. Then it will still scroll the wrong ListView but at the last second, scroll the correct ListView.
driver.execute_script("flutter:waitFor", scrollLocator, waitTime)
driver.execute_script("flutter:scrollUntilVisible", scrollLocator, {"item":locator, "dxScroll":0, "dyScroll":-300, "waitTimeoutMilliseconds": waitTime})
Scroll until visible not working below is the version Appium version -2.21 flutter@2.4.2 [installed (npm)] scrolling continuously even the element found.
// java
{ WebElement year1 = find.byValueKey("scroll_2"); WebElement textField = find.byText(year); JavascriptExecutor executor = driver; executor.executeScript("flutter:scrollUntilVisible", year1, ImmutableMap.of( "item",textField, "dxScroll",0, "dyScroll",-300, )); }
below is the error log for particular scroll
"<< {"isError":false,"response":{},"type":"_extensionType","method":"ext.flutter.driver"} | previous command scroll
[FlutterDriver] >>> {"command":"waitFor","text":"1999","finderType":"ByText","timeout":100}
[FlutterDriver] >>> {"command":"scroll","keyValueType":"String","keyValueString":"scroll_2","finderType":"ByValueKey","dx":0,"dy":-300,"duration":100000,"frequency":60}"
@KazuCocoa
I've tried a few of the scroll methods but none of them seem to be working (python, flutter, iOS)
Environment
iPad Pro 16.6.1
flutter:scrollIntoView Error
command:
error: