SSH Library Robot Framework Example : Hello world

In this article, we will see how to use ssh library for running a hello world test case on a remote machine.
This article is meant as introduction to RIDE, for details scenarios and explanation refer here

Verify Robot Framework installation

For this exercise we will using windows10 machine where robotframework and robotframework IDE is installed.
You can verify the installtion of packages with the below commands.

pip3 show robotframework|findstr Version
pip3 show robotframework-ride|findstr Version

If the above commands are not giving outputs, this signifies that package/s is not installed.
For setting up the Robotframework and RIDE on windows 10, refer to and follow the steps mentioned here

Install SSH Library for Robot Framework

We need to install SSH Library on the machine where robot framework is installed. SSH Library contains keywords designed and written for SSH operations.
The below command can be used for installing ssh library

pip3 install robotframework-sshlibrary --no-cache-dir command

Verify the ssh library installation

C:\Users\****>pip3 show robotframework-sshlibrary
Name: robotframework-sshlibrary
Version: 3.8.0
Summary: Robot Framework test library for SSH and SFTP
Author: Robot Framework Developers
Author-email: [email protected]
License: Apache License 2.0

Test case for executing echo “Hello world”

Create Test Suite and import SSH Library

  • Open the RIDE by executing python <installationpath>/ command on windows cmd or use the desktop shortcut which we have created previously (Refer link if you don't have a desktop shortcut)
  • Create a new project by
    • clicking File --> New Project ( Commonly called Test Suite) or by executing the shortcut Ctrl + N. 
    • Provide a project name In my case I'm naming it SSH Hello World.
    • Make sure the type is file and the format can be either text or Robot in my case I'm using Robot

New project creation

Test suite creation in Robot

  • Once Test Suite is created, Add/Import SSH Library to the suite.
    • Click on the test suite name SSH Hello World --> Library --> In Name Enter SSH Library ( no need to browse for the path as it is pre installed in the default path)

Add SSH Library to Robot

Create Testcase Hello World

  • SSH Library provides us a wide variety of Keywords among which it is the user's choice to select keywords as per their requirement. You can read more on the SSH Library on the official website
  • Right Click on the Testsuite name and select "New Test Case" or you can use the shortcut Ctrl + Shift + T , provide a name for the test case and click ok.
    • In my case, i will name it as Helloworld

Create a new Testcase

Before writing test case, it is good practice to write the test scenario or flow. In our case, we are printing helloworld to a remote machine via ride

Test scenario

Below is the step by step execution flow of our test case

  1. Establish connection to the remote machine
  2. Login to the remote machine
  3. Execute the command
  4. Set SSH prompt
  5. Read the output until the prompt is appeared
  6. Logout

Test scenario implementation

Below is the keyword usage in each step mentioned in the test scenario

  1. use Open Connection keyword for opening connection
    • Ip address of the linux machine is passed asargument
  2. SSHLibrary.Login keyword for login to the machine
    • Username and password is passed as argument
  3. Write keyword for writing the shell command
    • Command to be executed is passed as argument
  4. Set Client Configuration for prompt
    • Prompt is passed as an argument
  5. Read Until Prompt keyword for reading the output until the prompt set at step4 is obtained
    • Output is stored in a variable
  6. Close connection

The below screenshot shows the complete test case

Test case steps

Once the test case is written, you can execute the test case by pressing "F8" key or play button. The below snippet shows the play button and output of successful execution. In the output screen we will be able to see the log file location also

Successful test execution output


Log Analysis

  • On a successful or failed test execution, logs can be used for analsying the execution
  • In the above picture, we could see html log files are generated and we will be able to open this log file in any of the browsers
  • The log file will be truncated we can expand the logs by pressing the "+"  icon
  • For our test scenario, we will see Helloworld as the output in the log

Log analysis


In this article, we saw

  • How to install ssh Library
  • How to import ssh library to a Test suite
  • How to create a Testsuite and Testcase
  • SSH Library Robot framework Example

Search on LinuxDataHub

Leave a Comment