How to get the coordinates of control

A, MonkeyRecorder get coordinates

  (1) Start MonkeyRecorder

  1. First real machine or emulator connected to the computer; - to a god simulator, for example, cmd enter adb connect 127.0.0.1:62001
  2. After successful connection, cmd input view the name adb devices connected-device or device simulator;
  3. Input cmd monkeyrunner, enter the following command sequence:

  from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice      -- 导入MonkeyRunner,MonkeyDevice 包

  from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder - introducing MonkeyRecorder package, alias recorder

  device = MonkeyRunner.waitForConnection () - equipment to be connected

  recorder.start (device) - boot device by way MonkeyRecorder

          4. officially launched MonkeyRecorder

       (2) MonkeyRecorder

  1. Such as QQ login screen, click the login button, the button appears to the right coordinates, that is, we need to get the coordinates of the coordinates;
  2. MonkeyRecorder simulator interface in the same page is consistent, in MonkeyRecorder any of the trigger, the trigger will be a corresponding emulator. If the two are not consistent, then click on the upper right corner of MonkeyRecorder Refresh Display to refresh the page.

Two, uiautomatorviewer gets control coordinates

  1. uiautomatorviewer is android-sdk own tool (path: D: \ Android \ android-sdk \ tools)
  2. Tool Open Method: D: \ Android \ android-sdk \ tools, found uiautomatorviewer.bat, double-click to open; or open cmd input uiautomatorviewer
  3. Usually the midpoint coordinates to the coordinates of the control, the middle coordinate = ((the top left bottom right abscissa abscissa +) / 2, (upper left corner of the lower right corner ordinate ordinate +) / 2)

    In the following figure, i.e. the mid-point coordinates ((30 + 1009) / 2, (268 + 314) / 2) = (519.5,291)

    PS: - coordinates rounding.

Third, the use developer options Android devices to get the coordinates

  1. Open developer mode, to find the pointer position and open;

  

        2. When sliding the finger on the screen, can see the coordinates X, Y-axis at the top of the current touch point

   3.PS: Developer options are not visible by default, you need to enable developer mode on their own, and then after this operation. (To set the developer options, Baidu own ...)

 

Reference Links: https://www.cnblogs.com/du-hong/p/11211572.html

 

Guess you like

Origin www.cnblogs.com/huainanhai/p/11787426.html