Author: Stefan Zimmermann


        Robot Framework Tools

[Python]( Tools for [Robot Framework]( and Test Libraries.

* A [`testlibrary`][1] framework for creating Dynamic Test Libraries.

* A [`ContextHandler`][1.1] framework for `testlibrary`
  to create switchable sets of different Keyword implementations.

* A [`SessionHandler`][1.2] framework for `testlibrary`
  to auto-generate Keywords for session management.

* A [`TestLibraryInspector`][2].

* An interactive [`TestRobot`][3].

* A [`RemoteRobot`][4], combining `TestRobot`
  with external [`RobotRemoteServer`](

* A [`ToolsLibrary`][5],
  accompanying Robot Framework's standard Test Libraries.

* A [`robotshell`][6] extension for [IPython](

0. Setup

Supported __Python__ versions: __2.7.x__, __3.3.x__ and later

Package name: __robotframework-tools__

Package extra features:

* __[remote]__: `RemoteRobot`
* __[robotshell]__

### Requirements

* [``](
* [`moretools >= 0.1a34`](
* [`robotframework >= 2.8`](
  * __Python 3.x__: [`robotframework-python3 >= 2.8.3`](

Extra requirements for __[remote]__:

* [`robotremoteserver`](

Extra requirements for __[robotshell]__:

* [`ipython`](

### Installation

    python install

Or with [pip](

    pip install .

Or from [PyPI](

    pip install robotframework-tools

* With all extra features:

        pip install robotframework-tools[remote,robotshell]

1. Creating Dynamic Test Libraries
[1]: #markdown-header-1-creating-dynamic-test-libraries

    from robottools import testlibrary

    TestLibrary = testlibrary()

Defined in a module also called `TestLibrary`,
this generated Dynamic `TestLibrary` type
could now directly be imported in Robot Framework.
It features all the required methods:

* `get_keyword_names`
* `get_keyword_arguments`
* `get_keyword_documentation`
* `run_keyword`

### Keywords

The `TestLibrary` has no Keywords so far...
To add some just use the `TestLibrary.keyword` decorator:

    def some_keyword(self, arg, *rest):

A keyword function can be defined anywhere in any scope.
The `TestLibrary.keyword` decorator
always links it to the `TestLibrary`
(but always returns the original function object).
And when called as a Keyword from Robot Framework
the `self` parameter will always get the `TestLibrary` instance.

You may want to define your keyword methods
at your Test Library class scope.
Just derive your actual Dynamic Test Library class from `TestLibrary`:


    class SomeLibrary(TestLibrary):
        def no_keyword(self, ...):

        def some_other_keyword(self, arg, *rest):

To get a simple interactive `SomeLibrary` overview just instantiate it:

    In : lib = SomeLibrary()

You can inspect all Keywords in Robot CamelCase style
(and call them for testing):

    In : lib.SomeKeyword
    Out: SomeLibrary.Some Keyword [ arg | *rest ]

By default the Keyword names and argument lists are auto-generated
from the function definition.
You can override that:

    @TestLibrary.keyword(name='KEYword N@me', args=['f|r$t', 'se[ond', ...])
    def function(self, *args):

### Keyword Options

When you apply custom decorators to your Keyword functions
which don't return the original function objects,
you would have to take care of preserving the original argspec for Robot.
`testlibrary` can handle this for you:

    def some_decorator(func):
        def wrapper(...):
            return func(...)

        # You still have to take care of the function(-->Keyword) name: