BruceyBandit
BruceyBandit

Reputation: 4324

scroll method not performing the scroll in the android app

Below is the code:

AndroidDriver androidDriver;

public void scrollDown() {

    androidDriver.getCapabilities().getCapability("hub");

    androidDriver.manage().window().getSize();
    Dimension size = androidDriver.manage().window().getSize();
    int startX = size.width / 2;
    int startY = (int) (size.height * 0.60);
    int endY = (int) (size.height * 0.30);
    new TouchAction(androidDriver).longPress(startX, startY).moveTo(startX, endY).release().perform();

}

I tried including a waitAction but still doesn't work:

new TouchAction(androidDriver).longPress(startX, startY).waitAction(Duration.ofSeconds(3)).moveTo(startX, endY).release().perform();

I even tried including swiping but it doesn't swipe:

//        new TouchAction(androidDriver)
//                .press(PointOption.point(startX, startY))
//                .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3)))
//                .moveTo(PointOption.point(startX, endY))
//                .release().perform();

Basically the startX and startY within the longPress is underline red but this code did work before, but now I get a red line. The other thing is I changed the Android driver so it gets the capability from 'hub' which is set within Serenity properties like so (xxx out values):

webdriver.driver= appium
appium.hub = http://xxx.xxx.xxx.xxx:xxx/wd/hub
appium.automationName=appium
appium.platformName = Android
appium.app= ./xxxdebug.apk
appium.appPackage = xxx.debug
appium.appWaitActivity = xxx.StartupActivity
#appium.browserName =
serenity.take.screenshots= AFTER_EACH_STEP
webdriver.timeouts.implicitlywait = 10000
appium.fullReset=true
appium.noReset=false
logging = "VERBOSE"

Upvotes: 0

Views: 402

Answers (2)

Bill Hileman
Bill Hileman

Reputation: 2838

I believe your problem lies in that you are not using PointOption parameters:

    TouchAction touchAction = new TouchAction(driver);

    touchAction.longPress(PointOption.point(startx, starty))
               .moveTo(PointOption.point(endx, endy))
               .release()
               .perform();

Upvotes: 2

KotlinIsland
KotlinIsland

Reputation: 867

Here is what I use in Kotlin :

    fun setScrollViewToTop() {
    android.os.Handler().postDelayed({
        try {
            activity!!.findViewById<ScrollView>(R.id.scrollViewActivity).fullScroll(ScrollView.FOCUS_UP)
        } catch (t: Throwable) {
        }
    }, 125)
}

Upvotes: 0

Related Questions