how do you get the values of x and y? How do you determine the end of the screen?

0

I am doing some automatic tests of an application, I use uiautomatorviewer but it does not locate the arrow button to go backwards. I want to click with some coordinates, but depending on the device, these coordinates vary.

My idea was to put the axis and to the end of the screen and then subtract some pixels and the X axis to the right side. How could I put the end of the screen in this method:

public void tapCoordenada(int x, int y) {
    TouchAction touchAction = new TouchAction(getDriver());
    touchAction.tap(new PointOption().withCoordinates(x, y)).perform();
}
    
asked by Juan 18.10.2018 в 17:25
source

1 answer

0

Here is a way to get the coordinates of touch, I hope it works:

Display mdisp = getWindowManager().getDefaultDisplay();
Point mdispSize = new Point();
mdisp.getSize(mdispSize);
int maxX = mdispSize.x; 
int maxY = mdispSize.y;

For devices that have an older version of API 13:

Display mdisp = getWindowManager().getDefaultDisplay();
int maxX= mdisp.getWidth();
int maxY= mdisp.getHeight();

(x, y): -

1) (0,0) is upper left corner.

2) (maxX, 0) is upper right corner

3) (0, maxY) is lower left corner

4) (maxX, maxY) is lower right corner

    
answered by 19.10.2018 / 12:12
source