Hello everyone. Im trying to scroll 1989 in date picker. But its not scrolling.
Here what i try:
Tried this.
public WebElement scrollToElementByText(AppiumDriver driver) {
return driver.findElement(AppiumBy.androidUIAutomator(“new UiScrollable(new UiSelector().resourceIdMatches(”.*id/date_picker_year_picker").scrollable(true)).flingBackward()"));
And also this:
public WebElement scrollToElementByText(AppiumDriver driver, String text) {
return driver.findElement(AppiumBy.androidUIAutomator(
“new UiScrollable(new UiSelector()” + “.scrollable(true)).scrollIntoView(”
+ “new UiSelector().text(”"+text+""));"));
Can anyone help me please?
@Aleksei hey! Can u help me with that
Aleksei
November 25, 2023, 8:19am
3
In many cases it does not work here. I use tap above and below to descrease/increase value and chech is new value correct now. On android this works quite fast.
can u share the code please @Aleksei , i will try and will tell u the result.
Aleksei
November 25, 2023, 1:49pm
5
You need just add your elements and adapt a bit code per your framework.
@Step("Set 'Year' {year}")
public CreditEmployerPage setYear(String year) {
Logger.log();
if (isIOS)
Assert.assertTrue(setValuePickerWheel_iOS(yearSelector, year), createAssertionLog("FAILED"));
else {
int counter = 0;
Integer resultInt;
int yearInt = getNumberValueFromString(year, Integer.class);
setLookTiming(3);
do {
resultInt = getNumberValueFromString(getText(yearSelector), Integer.class);
if (resultInt == null) // == yearSelector NOT found
break;
// log("current year = " + resultInt + ", vs " + year);
if (resultInt == yearInt)
break;
else if (resultInt > yearInt) {
// log("current year = up");
tap(yearSelectorButtons.get(0), resultInt - yearInt); // here we do several taps
} else {
// log("current year = down");
tap(yearSelectorButtons.get(1), yearInt - resultInt);
}
counter++;
sleep(100);
} while (counter < 4); // here i allow 4 tries
String result = getText(yearSelector);
setDefaultTiming();
// double check
Assert.assertEquals(result, year, createAssertionLog("FAILED"));
}
return this;
}
}