简体   繁体   中英

Scroll down android device using adb command - how to know i reached the end?

So I am scroll down my device using this command:

count = 0

while count < 5:
    subprocess.run('adb shell input swipe 500 1000 300 300')
    time.sleep(2)
    count += 1

I do this several times but how do I know when I have reached the end?

The input command cannot give you feedback whether you have reached the end or not, you'll have to check the screen itself - get the screen's state after every swipe and compare it to the previous one.
For checking the screen's state I can think about 2 options:

  1. Use the screencap command to take a screenshot of your device.
  2. Use the uiautomator dump command to get an XML of the screen.

In both cases you'll have to ignore parts of the scrren which MAY change, but have no meaning in your use case, like the clock that is displayed at the top of the screen and may change during your scrolling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM