Getting Object Screen Position, Location, Coordinates (AWT, Swing)

Last edited on


It can be useful to know an object's absolute screen position: for example when using Squish's nativeMouseClick() function.

def main():

    pos = waitForObject(nameOfObject).getLocationOnScreen()
    test.log("x=%d, y=%d" % (pos.x, pos.y))

Squish's waitForObject() function returns a reference to the corresponding AUT object. Such objects' Java APIs can be used freely: here, for example, we have called the object's getLocationOnScreen() method.

More Information