autopilot.process.ProcessManager

class autopilot.process.ProcessManager

A simple process manager class.

The process manager is used to handle processes, windows and applications. This class should not be instantiated directly however. To get an instance of the keyboard class, call create instead.

KNOWN_APPS = {'System Settings': {'process-name': 'unity-control-center', 'desktop-file': 'unity-control-center.desktop'}, 'Mahjongg': {'process-name': 'gnome-mahjongg', 'desktop-file': 'gnome-mahjongg.desktop'}, 'Text Editor': {'process-name': 'gedit', 'desktop-file': 'gedit.desktop'}, 'Terminal': {'process-name': 'gnome-terminal', 'desktop-file': 'gnome-terminal.desktop'}, 'Character Map': {'process-name': 'gucharmap', 'desktop-file': 'gucharmap.desktop'}, 'Remmina': {'process-name': 'remmina', 'desktop-file': 'remmina.desktop'}, 'Calculator': {'process-name': 'gnome-calculator', 'desktop-file': 'gcalctool.desktop'}}
static create(preferred_backend='')

Get an instance of the ProcessManager class.

For more infomration on picking specific backends, see Advanced Backend Picking

Parameters:preferred_backend

A string containing a hint as to which backend you would like. Possible backends are:

  • BAMF - Get process information using the BAMF Application
    Matching Framework.
Raises:RuntimeError if autopilot cannot instantate any of the possible backends.
Raises:RuntimeError if the preferred_backend is specified and is not one of the possible backends for this device class.
Raises:BackendException if the preferred_backend is set, but that backend could not be instantiated.
classmethod register_known_application(name, desktop_file, process_name)

Register an application with autopilot.

After calling this method, you may call start_app or start_app_window with the name parameter to start this application. You need only call this once within a test run - the application will remain registerred until the test run ends.

Parameters:
  • name – The name to be used when launching the application.
  • desktop_file – The filename (without path component) of the desktop file used to launch the application.
  • process_name – The name of the executable process that gets run.
Raises:

KeyError if application has been registered already

classmethod unregister_known_application(name)

Unregister an application with the known_apps dictionary.

Parameters:name – The name to be used when launching the application.
Raises:KeyError if the application has not been registered.
start_app(app_name, files=[], locale=None)

Start one of the known applications, and kill it on tear down.

Warning

This method will clear all instances of this application on tearDown, not just the one opened by this method! We recommend that you use the start_app_window method instead, as it is generally safer.

Parameters:
  • app_name – The application name. This name must either already be registered as one of the built-in applications that are supported by autopilot, or must have been registered using register_known_application beforehand.
  • files – (Optional) A list of paths to open with the given application. Not all applications support opening files in this way.
  • locale – (Optional) The locale will to set when the application is launched. If you want to launch an application without any localisation being applied, set this parameter to ‘C’.
Returns:

A Application instance.

start_app_window(app_name, files=[], locale=None)

Open a single window for one of the known applications, and close it at the end of the test.

Parameters:
  • app_name – The application name. This name must either already be registered as one of the built-in applications that are supported by autopilot, or must have been registered with register_known_application beforehand.
  • files – (Optional) Should be a list of paths to open with the given application. Not all applications support opening files in this way.
  • locale – (Optional) The locale will to set when the application is launched. If you want to launch an application without any localisation being applied, set this parameter to ‘C’.
Raises:

AssertionError if no window was opened, or more than one window was opened.

Returns:

A Window instance.

get_open_windows_by_application(app_name)

Get a list of ~autopilot.process.Window` instances for the given application name.

Parameters:app_name – The name of one of the well-known applications.
Returns:A list of Window instances.
close_all_app(app_name)
get_app_instances(app_name)
app_is_running(app_name)
get_running_applications(user_visible_only=True)

Get a list of the currently running applications.

If user_visible_only is True (the default), only applications visible to the user in the switcher will be returned.

get_running_applications_by_desktop_file(desktop_file)

Return a list of applications with the desktop file desktop_file.

This method will return an empty list if no applications are found with the specified desktop file.

get_open_windows(user_visible_only=True)

Get a list of currently open windows.

If user_visible_only is True (the default), only applications visible to the user in the switcher will be returned.

The result is sorted to be in stacking order.

wait_until_application_is_running(desktop_file, timeout)

Wait until a given application is running.

Parameters:
  • desktop_file (string) – The name of the application desktop file.
  • timeout (integer) – The maximum time to wait, in seconds. If set to something less than 0, this method will wait forever.
Returns:

true once the application is found, or false if the application was not found until the timeout was reached.

launch_application(desktop_file, files=[], wait=True)

Launch an application by specifying a desktop file.

Parameters:files (List of strings) – List of files to pass to the application. Not all apps support this.

Note

If wait is True, this method will wait up to 10 seconds for the application to appear.

Raises:TypeError on invalid files parameter.
Returns:The Gobject process object.