How to scroll on a specific character of the screen(Android)?

I have to scroll on a specific character on the screen. Can anybody help me out?

@jitenderbhardwaj you mean e.g. with input text string like “Test” put cursor into between “e” and “s” for example?

@Aleksei
Actually, it a date picker and i need to scroll it up in order to choose the date and time.
I tried with all other possible ways but didn’t get succeed.
The only way left is to scroll on the point where the date selector is present.

@jitenderbhardwaj send screenshot of your day picker to easier understand everyone

@Aleksei
The marked area is the date picker.
Here is the screenshot:- DatePicker

@jitenderbhardwaj aga! so you have custom picker. did you try just tap up/down and check picker value?

Tried .sendkeys with classname, xpath, but didn’t work.
Tried. gettin list of all available elements and then .sendkeys, nothing works!

@jitenderbhardwaj no i mean e.g. tap on “WED Aug 23” and check that current value changed correctly to same?

@Aleksei Tried but not working!

@jitenderbhardwaj can you be more specific please? what not working? you cant tap? not changing visually value? not changing value in code?

Can’t tap. Not changing visual value. And not giving errors too. It means the element path is correct and the element is inspected but the action didn’t perform on it.

@jitenderbhardwaj so we have problem in tap :slight_smile: can you share pageSource to check at https://gist.github.com/ ? you can hide all your specific in it just leave ids and whole structure.

The script written by me to automate app? Or something else?

@jitenderbhardwaj your tap code script itself will be usefull but we need:

System.out.println(driver.getPageSource())

on this screen to see it elements.

I have added the page source file. And here is the URL:- https://gist.github.com/anonymous/4dfbf7037d8f4040702fa5e769c19ef3

@jitenderbhardwaj here is code to try:

Page object itself:

package com.zzzzz.pages.android;

import com.zzzz.base.Page;
import io.appium.java_client.MobileDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.HowToUseLocators;
import io.appium.java_client.pagefactory.LocatorGroupStrategy;
import org.openqa.selenium.WebDriver;

import java.time.Duration;
import java.util.List;

public class TestPage extends Page {

    @HowToUseLocators(androidAutomation = LocatorGroupStrategy.CHAIN)
    @AndroidFindBy(id = "picker_container")
    @AndroidFindBy(id = "numberpicker_input")
    private List<AndroidElement> pickerInputs;

    @HowToUseLocators(androidAutomation = LocatorGroupStrategy.CHAIN)
    @AndroidFindBy(id = "picker_container")
    @AndroidFindBy(className = "android.widget.Button")
    private List<AndroidElement> pickerButtons;

    public TestPage(WebDriver driver) {
        super(driver);
    }

    public boolean tapPickerButton(int num) {
        System.out.println("  tapPickerButton(): " + num);
        return tapElement(pickerButtons.get(num));
    }

    public String getPickerInputValue(int num) {
        System.out.println("  getPickerInputValue(): " + num);
        return pickerInputs.get(num).getText();
    }

    public boolean setPickerInputValue(int num, String input) {
        System.out.println("  getPickerInputValue(): " + num);
        try {
            pickerInputs.get(num).setValue(input);
            return true;
        } catch (Exception e) {
            // picker input num NOT found
            return false;
        }
    }

    public boolean tapElement(MobileElement element) {
        try {
            new TouchAction((MobileDriver) driver).press(element).waitAction(Duration.ofMillis(70)).release().perform();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}

now test code itself:


        TestPage testPage = new testPage(driver);
        System.out.println("First picker value is: " + testPage.getPickerInputValue(1));
        assertTrue("some error text", testPage.tapPickerButton(1));
        System.out.println("First picker value changed to: " + testPage.getPickerInputValue(1));

You can watch : https://www.youtube.com/playlist?list=PLXbcghgSZDroz9nez1IrbL2hnMVJ0ba1W

driver.scrollTo(“Text”);

@Cihangir_Tuna I don’t have to pass static text, i want to scroll two to three values down. how to achieve that?