:mod:`dip.automate`
===================
.. module:: dip.automate

The :mod:`dip.automate` module contains a collection of classes that allow
an application to be automated.


:class:`AutomationCommands`
---------------------------
.. class:: AutomationCommands

    Base class: :class:`~dip.model.Model`

    The AutomationCommands class is the base class for recording a sequence
    of commands to automate part of an application.

    .. attribute:: sequence = Int()

        The sequence number that defines the order in which this instance was
        created relative to other instances.  This is used to ensure that
        automation commands defined in the same .py file are applied in the order
        that they are created in the file.

    .. attribute:: value = Any()

        An optional value that can be passed to __init__ and used by record().

    .. method:: AutomationCommands.__init__(value=None)

        Initialise the object. 

    .. method:: AutomationCommands.record(robot)

        Record a sequence of automation commands for a user interface using
        a robot.
        
        :param robot:
            is the :class:`~dip.automate.Robot` to use to record the commands.


:exc:`AutomationError`
----------------------
.. exception:: AutomationError

    Base exception: :class:`~builtins.Exception`

    The AutomationError exception is raised when an automated command
    cannot be executed.


:class:`IAutomated`
-------------------
.. class:: IAutomated

    Base class: :class:`~dip.model.Interface`

    The IAutomated interface is the base interface for all interfaces that
    define the APIs of automated items.


:class:`IAutomatedActionTrigger`
--------------------------------
.. class:: IAutomatedActionTrigger

    Base class: :class:`~dip.automate.IAutomated`

    The IAutomatedActionTrigger interface defines the API of automated
    widgets that trigger actions.

    .. method:: IAutomatedActionTrigger.simulate_trigger(id, delay, action_id)

        Simulate the user triggering an action.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param action_id:
            is the identifier of the action.


:class:`IAutomatedDialog`
-------------------------
.. class:: IAutomatedDialog

    Base class: :class:`~dip.automate.IAutomated`

    The IAutomatedDialog interface defines the API of automated dialogs.
        

    .. method:: IAutomatedDialog.simulate_click(id, delay, button)

        Simulate the user clicking a button.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param button:
            is the button to click.


:class:`IAutomatedEditor`
-------------------------
.. class:: IAutomatedEditor

    Base class: :class:`~dip.automate.IAutomated`

    The IAutomatedEditor interface defines the API of automated editors.
        

    .. method:: IAutomatedEditor.simulate_set(id, delay, value)

        Simulate the user setting the editor value.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param value:
            is the value to set.


:class:`IAutomatedListEditor`
-----------------------------
.. class:: IAutomatedListEditor

    Base class: :class:`~dip.automate.IAutomated`

    The IAutomatedListEditor interface defines the API of automated editors
    that handle lists.

    .. method:: IAutomatedListEditor.simulate_append(id, delay, value)

        Simulate the user appending a value to the list.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param value:
            is the value to append.

    .. method:: IAutomatedListEditor.simulate_move(id, delay, from_index, to_index)

        Simulate the user moving a value within the list.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param from_index:
            is the initial index of the value being moved.
        :param to_index:
            is the final index of the value being moved.

    .. method:: IAutomatedListEditor.simulate_remove(id, delay, index)

        Simulate the user removing a value from the list.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param index:
            is the index of the value to remove.

    .. method:: IAutomatedListEditor.simulate_update(id, delay, value, index, column=None)

        Simulate the user updating a value in the list.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param value:
            is the new value.
        :param index:
            is the index of the value to update.
        :param column:
            is the name of the attribute within the model to update.  It should
            not be specified if the list's elements are a simple type.


:class:`IAutomatedOptionSelector`
---------------------------------
.. class:: IAutomatedOptionSelector

    Base class: :class:`~dip.automate.IAutomated`

    The IAutomatedOptionSelector interface defines the API of automated
    editors that handle lists of options.

    .. method:: IAutomatedOptionSelector.simulate_select(id, delay, index)

        Simulate the user selecting an item.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param index:
            is the index of the option.


:class:`IAutomatedShell`
------------------------
.. class:: IAutomatedShell

    Base class: :class:`~dip.automate.IAutomatedActionTrigger`

    The IAutomatedShell interface defines the API of automated shells. 


:class:`IAutomatedTabBar`
-------------------------
.. class:: IAutomatedTabBar

    Base class: :class:`~dip.automate.IAutomated`

    The IAutomatedTabBar interface defines the API of automated tab bars.
        

    .. method:: IAutomatedTabBar.simulate_select(id, delay, index)

        Simulate the user selecting a tab page.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param index:
            is the index of the tab page.


:class:`IAutomatedTableEditor`
------------------------------
.. class:: IAutomatedTableEditor

    Base class: :class:`~dip.automate.IAutomated`

    The IAutomatedTableEditor interface defines the API of automated
    editors that handle tables.

    .. method:: IAutomatedTableEditor.simulate_append(id, delay, values)

        Simulate the user appending a row to the table.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param values:
            is the sequence of values to append.

    .. method:: IAutomatedTableEditor.simulate_move(id, delay, from_row, from_column, to_row, to_column)

        Simulate the user moving a value within the table.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param from_row:
            is the initial row of the value being moved.
        :param from_column:
            is the initial column of the value being moved.
        :param to_row:
            is the final row of the value being moved.
        :param to_column:
            is the final column of the value being moved.

    .. method:: IAutomatedTableEditor.simulate_remove(id, delay, row)

        Simulate the user removing a row from the table.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param row:
            is the row to remove.

    .. method:: IAutomatedTableEditor.simulate_update(id, delay, value, row, column)

        Simulate the user updating a value in the table.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param value:
            is the new value.
        :param row:
            is the row of the value to update.
        :param column:
            is the column of the value to update.


:class:`IAutomatedTrigger`
--------------------------
.. class:: IAutomatedTrigger

    Base class: :class:`~dip.automate.IAutomated`

    The IAutomatedTrigger interface defines the API of automated editors
    that handle triggers.

    .. method:: IAutomatedTrigger.simulate_trigger(id, delay)

        Simulate the user pulling the trigger.
        
        :param id:
            is the (possibly scoped) identifier of the widget.  This is
            normally used in exceptions.
        :param delay:
            is the delay in milliseconds between simulated events.


:class:`Robot`
--------------
.. class:: Robot

    Base class: :class:`~dip.model.Model`

    The Robot class manages the automation commands that can be executed by
    a user interface.

    .. attribute:: delay = Int(-1)

        The default delay in milliseconds between the playing of individual
        automation commands.

    .. attribute:: timeout = Int(-1)

        The default time in milliseconds to wait for a user interface widget to
        be visible.

    .. method:: Robot.clear()

        Any recorded automation commands are discarded. 

    .. method:: Robot.play(after=-1)

        Any recorded automation commands are executed.
        
        :param after:
            is the delay in milliseconds after the start of an event loop
            before the commands are executed.  If the value is negative then
            the commands are played immediately without waiting for an event
            loop to start.

    .. method:: Robot.record(id, command, *command_args, delay=-1, timeout=-1)

        Record an automation command.
        
        :param id:
            is the (possibly scoped) identifier of the widget to apply the
            command to.
        :param command:
            is the name of the command to record.
        :param \*command_args:
            are the commands's arguments.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param timeout:
            is the time in milliseconds to wait for the user interface widget
            to become visible.

    .. staticmethod:: Robot.simulate(id, command, *command_args, delay=-1, timeout=-1)

        Immediately execute an automation command.
        
        :param id:
            is the (possibly scoped) identifier of the widget to apply the
            command to.
        :param command:
            is the name of the command to execute.
        :param \*command_args:
            are the command's arguments.
        :param delay:
            is the delay in milliseconds between simulated events.
        :param timeout:
            is the time in milliseconds to wait for the user interface widget
            to become visible.