Home > Blockchain >  Incorrect button location in dumpsys activity on emulator
Incorrect button location in dumpsys activity on emulator

Time:11-26

  1. On a new Virtual Device (Pixel 4, api version 30, Android 11) I open Chrome, and click "Accept & Continue" on the Welcome to Chrome Screen.
  2. At this point Chrome in is on "Turn on Sync" screen and there is a "No thanks" button on the screen.
  3. Then I switch to the terminal on my mac and run adb shell dumpsys activity top

Result contains following lines:

org.chromium.chrome.browser.signin.AccountSigninView{1080,0-2160,1977}
  android.widget.LinearLayout{0,1790-1080,1977 #7f0b009c app:id/button_bar}
     org.chromium.ui.widget.ButtonCompat{44,44-299,143 #7f0b02d1 app:id/negative_button}

AccountSigninView has coordinates 1080,0-2160,1977 that are outside of the screen, but the button is visible on the screen. This behaviour is not reproduced on my phone.

Questions:

  1. How can I understand that this button is actually visible and not outside of the screen?
  2. How can adjust emulator so that it has the same behaviour as my regular phone?

Update 1:

I tried running adb shell uiautomator dump and although there are no controls outside of screen bounds, the coordinates of button are zero.

<node
  resource-indroid.chrome:id/negative_button"
  ...
  bounds="[0,0][0,0]"/>

CodePudding user response:

I don't know exactly how to parse the output of dumpsys acticity top, but the 1080 and 2160 are the upper y and lower y coordinates of the layout. As to the other 2 numbers - I don't know how to parse them.
If you want to get the bounds of any view, you better use the uiautomator dump command. It outputs an xml file, where you can find the bounds of any view in the screen.

CodePudding user response:

You can try AndroidViewClient/culebra which uses uiautomator or other backends if available and also can do some adjustments to the coordinates, for example running

dump --bounds

in a similar situations (Chrome has already been setup), gives

...
android.widget.Button com.android.chrome:id/signin_promo_choose_account_button Choose another account ((143, 1900), (937, 2032))
...

so if you intention is to click the button, using AndroidViewClient you can simply do

vc.findViewWithTextOrRaise(u'Choose another account').touch()
  • Related