autopilot.input - Generate keyboard, mouse, and touch input events

Autopilot unified input system.

This package provides input methods for various platforms. Autopilot aims to provide an appropriate implementation for the currently running system. For example, not all systems have an X11 stack running: on those systems, autopilot will instantiate input classes class that use something other than X11 to generate events (possibly UInput).

Test authors should instantiate the appropriate class using the create method on each class. Calling create() with no arguments will get an instance of the specified class that suits the current platform. In this case, autopilot will do it’s best to pick a suitable backend. Calling create with a backend name will result in that specific backend type being returned, or, if it cannot be created, an exception will be raised. For more information on creating backends, see Advanced Backend Picking

There are three basic input types available:

  • Keyboard - traditional keyboard devices.

  • Mouse - traditional mouse devices (Currently only avaialble on the

    desktop).

  • Touch - single point-of-contact touch device.

The Pointer class is a wrapper that unifies the API of the Mouse and Touch classes, which can be helpful if you want to write a test that can use either a mouse of a touch device. A common pattern is to use a Touch device when running on a mobile device, and a Mouse device when running on a desktop.

See also

Module autopilot.gestures
Multitouch and gesture support for touch devices.
autopilot.input.get_center_point(object_proxy)[source]

Get the center point of an object.

It searches for several different ways of determining exactly where the center is. The attributes used are (in order):

  • globalRect (x,y,w,h)
  • center_x, center_y
  • x, y, w, h
Raises:
  • ValueError – if object_proxy has the globalRect attribute but it is not of the correct type.
  • ValueError – if object_proxy doesn’t have the globalRect attribute, it has the x and y attributes instead, but they are not of the correct type.
  • ValueError – if object_proxy doesn’t have any recognised position attributes.