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.
- 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)
Please open the folder in VS Code and install the recommended extensions, listed in .vscode/extensions.json
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.
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.
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.
Use the test suites in the examples/0_check_installation folder - the tests should run without any errors.
The .gitpod.yml file contains some configuration which is used by Gitpod when creating a workspace from the repository.
- VS Code extensions to install
- Image selection and port configuration for desktop interaction
- Starting a web server and port configuration for Opening Robot Framework logs
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
.
- 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.
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.
- Introduction - why create your own library?
- Basic topics
- 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
- @library
- Module based libraries in Python (import as file)
- Dynamic libraries
- API methods
- New in RF 6.1 - interfaces in public API
- PythonLibCore - shortly
- Gives cetralized access to keywords implemented in multiple classes / files
- Useful for larger libraries
- https://github.com/robotframework/PythonLibCore
- Hybrid libraries
- Static libraries
- Large excercies
- Create a static library for automating an OpenAPI compatible REST API using the Python OpenAPI Client generator
- Create a dynamic library for automating an XML RPC application, using standard Python XML RPC client
- Publishing on PyPi
- Developing a library as package - install with pip -e
- What does a public library need?
- Readme
- License
- Version
- Official packaging guide
- Remote interface - if time allows