Skip to content

amochin/rf-libraries-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Robot Framework creating libraries workshop

Workspace usage

This is a workspace for docs and code samples for the workshop about creating libraries for Robot Framework. It can be used locally in VS Code and in Gitpod.

The workspace contains some VS Code configuration

  • List of recommended extensions
  • Some common RF and Python and settings
  • Launch config for RF Language Server extension for VS Code
    • It works after clicking on one of the code lense buttons Run or Debug above the test case name in .robot files
    • It enables saving all RF output files in the logs folder
    • It also sets the RF log level to DEBUG (with INFO as visible by default)

Local usage

Please open the folder in VS Code and install the recommended extensions, listed in .vscode/extensions.json

Usage in Gitpod

What is Gitpod?

Gitpod is an IDE in the cloud.

  • It opens VS Code in the browser without any local installation.
  • You'll need only a GitHub account (free) which you can use to login to Gitpod.
  • Gitpod is free for individual usage up to 50h per month - see pricing.

How to start

For this repository, you can use the prepared link:
Open the workspace in Gitpod

Or you can create a Gitpod workspace from any GitHub repository just pasting it's link in the New Workspace window.

Installing Robot Framework and libraries

Initially, the workspace has some common prerequisites installed, including Python, Node.js, Java and Docker. See the full list in the Gitpod docs.

However, the workspace contains neither Robot Framework nor any libraries or Python modules installed. You can install them as usual:
pip install -r requirements.txt

After initial Robot Framework installation, you might need to call the Reload window command to get the VS Code RF Language Server extension working - use Command Palette to find it.

Check your workspace is set up successfully

Use the test suites in the examples/0_check_installation folder - the tests should run without any errors.

Gitpod workspace configuration

The .gitpod.yml file contains some configuration which is used by Gitpod when creating a workspace from the repository.

Desktop interaction

In case of GUI test automation (e.g. a web app with playwright / Browser Library), it might be helpful to access the GUI / Desktop. In Gitpod workspace, you should use VNC for this.
The preconfigured image contains a VNC service running in the background on the port 6080.

The VNC client runs in the browser

  • When the workspace was started, you'll see a Simple Browser tab in VS Code with the VNC connection open.
  • You can also open the VNC connection in an external browser window
  • It's your browser, the same one where you have the Gitpod workspace VS Code running.

Opening Robot Framework logs

Robot Framework log and report output are HTML files, so they require a browser to be opened.
For whatever reason, the included browser of Gitpod workspace throws an error.

As a workaround, the workspace launches a simple web server running on the port 8080, serving the entire workspace directory.
So when you see a notification from VS Code, telling the port is open, click Open Browser - it opens a new browser window with all the files listed.

Simply navigate to the required folder (e.g. logs) and open the RF output files as usual.

  • It's your browser, the same one where you have the Gitpod workspace VS Code running.
  • You can also use a Simple Browser in VS Code for viewing RF logs, but you can't have two tabs of it - so either VNC or logs.

Workshop summary

  1. Introduction - why create your own library?
  2. Basic topics
    1. Static libraries
      • Module based libraries in Python (import as file)
        • Function --> keyword
        • Arguments
          • Positional args
          • Default values
          • *varargs and **kwargs
          • Argument conversion
            • manual
            • based on default value
            • type hints / function annotations
            • decorators
        • Returning values
          • Scalar values
          • Objects, lists, dictionaries
        • Failing / assertions (incl. RF own exceptions like ContinuableFailure)
        • Logging - use RF API or Python standard API
        • Library metadata (Scope, Version, Docs)
        • Select which functions become keywords
          • Naming
          • Decorators (@keyword, @not_keyword)
      • Libraries as Python classes
        • Import params -> constructors
        • Import as package - set PythonPath
        • Decorators
          • @library
            • Disables automatic keyword recognition
            • Can set metadata
    2. Dynamic libraries
    3. Hybrid libraries
  3. Large excercies
    1. Create a static library for automating an OpenAPI compatible REST API using the Python OpenAPI Client generator
    2. Create a dynamic library for automating an XML RPC application, using standard Python XML RPC client
  4. Publishing on PyPi
    • Developing a library as package - install with pip -e
    • What does a public library need?
      • Readme
      • License
      • Version
    • Official packaging guide
  5. Remote interface - if time allows

About

Docs and code samples for the workshop about creating libraries for Robot Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages