This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 22
Aug 2017

@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.

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

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 your tap code script itself will be usefull but we need:

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

on this screen to see it elements.

@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));