robot.utils.connectioncache
¶
ConnectionCache
¶
Cache for libraries to use with concurrent connections, processes, etc.
The cache stores the registered connections (or other objects) and allows switching between them using generated indices, user given aliases or connection objects themselves. This is useful with any library having a need for multiple concurrent connections, processes, etc.
This class is used also outside the core framework by SeleniumLibrary, SSHLibrary, etc. Backwards compatibility is thus important when doing changes.
Source code in src/robot/utils/connectioncache.py
register
¶
Registers given connection with optional alias and returns its index.
Given connection is set to be the :attr:current
connection.
If alias is given, it must be a string. Aliases are case and space insensitive.
The index of the first connection after initialization, and after
:meth:close_all
or :meth:empty_cache
, is 1, second is 2, etc.
Source code in src/robot/utils/connectioncache.py
switch
¶
Switches to the connection specified using the identifier
.
Identifier can be an index, an alias, or a registered connection. Raises an error if no matching connection is found.
Updates :attr:current
and also returns its new value.
Source code in src/robot/utils/connectioncache.py
get_connection
¶
Returns the connection specified using the identifier
.
Identifier can be an index (integer or string), an alias, a registered
connection or None
. If the identifier is None
, returns the
current connection if it is active and raises an error if it is not.
Raises an error also if no matching connection is found.
Source code in src/robot/utils/connectioncache.py
get_connection_index
¶
Returns the index of the connection specified using the identifier
.
Identifier can be an index (integer or string), an alias, or a registered connection.
New in Robot Framework 7.0. :meth:resolve_alias_or_index
can be used
with earlier versions.
Source code in src/robot/utils/connectioncache.py
resolve_alias_or_index
¶
Deprecated in RF 7.0. Use :meth:get_connection_index
instead.
Source code in src/robot/utils/connectioncache.py
close_all
¶
Closes connections using the specified closer method and empties cache.
If simply calling the closer method is not adequate for closing
connections, clients should close connections themselves and use
:meth:empty_cache
afterward.
Source code in src/robot/utils/connectioncache.py
empty_cache
¶
Empties the connection cache.
Indexes of the new connections starts from 1 after this.