Robot Framework test library for SSH and SFTP
Project description
Introduction
SSHLibrary is a Robot Framework test library for SSH and SFTP. The project is hosted on GitHub and downloads can be found from PyPI.
SSHLibrary is operating system independent and supports Python 2.7 as well as Python 3.4 or newer. In addition to the normal Python interpreter, it also works with Jython 2.7.
The library has the following main usages:
Executing commands on the remote machine, either with blocking or non-blocking behavior.
Writing and reading in an interactive shell.
Transferring files and directories over SFTP.
Ensuring that files and directories exist on the remote machine.
Documentation
See keyword documentation for available keywords and more information about the library in general.
For general information about using test libraries with Robot Framework, see Robot Framework User Guide.
Installation
The recommended installation method is using pip:
pip install --upgrade robotframework-sshlibrary
Running this command installs also the latest Robot Framework and paramiko versions. The minimum supported paramiko version is 1.15.0. The --upgrade option can be omitted when installing the library for the first time.
With recent versions of pip it is possible to install directly from the GitHub repository. To install latest source from the master branch, use this command:
pip install git+https://github.com/robotframework/SSHLibrary.git
Alternatively you can download the source distribution from PyPI, extract it, and install it using one of the following depending are you using Python or Jython:
python setup.py install jython setup.py install
A benefit of using pip is that it automatically installs paramiko and Cryptography modules (or PyCrypto if paramiko version < 2.0) that SSHLibrary requires on Python.
On Jython, SSHLibrary requires Trilead SSH JAR distribution. You need to download Trilead SSH JAR distribution and add it to CLASSPATH.
Usage
To use SSHLibrary in Robot Framework tests, the library needs to first be imported using the Library setting as any other library.
When using Robot Framework, it is generally recommended to write as easy-to-understand tests as possible. The keywords provided by SSHLibrary are pretty low level and it is typically a good idea to write tests using Robot Framework’s higher level keywords that utilize SSHLibrary keywords internally. This is illustrated by the following example where SSHLibrary keywords like Open Connection and Login are grouped together in a higher level keyword like Open Connection And Log In.
*** Settings ***
Documentation This example demonstrates executing a command on a remote machine
... and getting its output.
...
... Notice how connections are handled as part of the suite setup and
... teardown. This saves some time when executing several test cases.
Library SSHLibrary
Suite Setup Open Connection And Log In
Suite Teardown Close All Connections
*** Variables ***
${HOST} localhost
${USERNAME} test
${PASSWORD} test
*** Test Cases ***
Execute Command And Verify Output
[Documentation] Execute Command can be used to run commands on the remote machine.
... The keyword returns the standard output by default.
${output}= Execute Command echo Hello SSHLibrary!
Should Be Equal ${output} Hello SSHLibrary!
*** Keywords ***
Open Connection And Log In
Open Connection ${HOST}
Login ${USERNAME} ${PASSWORD}
Support
If the provided documentation is not enough, there are various support forums available:
robotframework-users mailing list
#sshlibrary and #sshlibrary-dev channels in Robot Framework Slack community
SSHLibrary issue tracker for bug reports and concrete enhancement requests
Other support forums including paid support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file robotframework-sshlibrary-3.0.0.tar.gz
.
File metadata
- Download URL: robotframework-sshlibrary-3.0.0.tar.gz
- Upload date:
- Size: 40.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a266bdcc2854fec8b40baf968e02b996e069964ae4b1ae84501c2f396a02276 |
|
MD5 | 4b3953d6761468f04f378eb3b44b5784 |
|
BLAKE2b-256 | a08786f8ff728977e8f9bd9325f0fe9c274ee29508a98dca66c40ad8bdb18f09 |