I'm looking for a way to detect if a screen changed from previous screen.. I mean: I have "Screen A" with full of buttons - I'm trying to press all of them, but only 1 of them will take me to "Screen B"..
I'm looking for a way that I could loop through all the buttons and break after reaching "Screen B" - via adb
I tried looking into uiautomator dump
from previous screen and after each click on a button getting the UI hierarchy of the "new" screen and comparing them - but results weren't successful.
Any ideas? Thanks
I'm assuming you have the adb
commands for input tap X Y
covered already.
I would recommend pulling a screencap
1 second before and after the input tap
and compare the screenshots to see if the screen changed. The code for screencap will look like this:
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.png
There are several ways to go about comparing the images. Since you're using Python you can easily compare pixels inside the image, but another method that I would use is compare the exact file size of the two images, a .jpg screenshot of the same screen will have the exact same file size, unless the clock in the upper right hand corner updated or other notifications rolled in. If there is a major size difference between screenshots of the two windows, you can use a simple greater-than/less-than if statement to determine.
Hope this helps,