Pipe is a Robot Framework Library that brings the pipe operator known from functional programming languages into Robot Framework. PipeLibrary is designed to enhance keyword chaining capabilities, it simplifies the process of passing the output of one keyword as an input to another, enabling more readable and maintainable test cases.
To install PipeLibrary, run the following command:
pip install robotframework-pipe
Here's a basic example to demonstrate the usage of the PipeLibrary:
*** Settings ***
Library PipeLibrary
*** Test Cases ***
Complex Operation With Pipe
Pipe Get User Id username
... >> Fetch User Details
... >> Process Data
... >> Validate User
... >> Log
Without Pipe, the same example would require intermediate variables:
Complex Operation Without Pipe
${user_id} = Get User Id username
${user_details} = Fetch User Details ${user_id}
${processed_data} = Process Data ${user_details}
${status} = Validate User ${processed_data}
Log ${status}
The PipeLibrary simplifies the process by removing the need for intermediate variables and making the flow of data between keywords more intuitive and cleaner.
Pipe
: The main keyword of the PipeLibrary.>>
: The pipe operator, used to chain keywords.Placeholder
: A symbol (default$
) used to denote where the output of the previous keyword should be placed in the next keyword's argument list. This is optional.
By default, the result of the keyword is used as the first argument of the next keyword. You can use the Placeholder to explicitly set the argument or import the PipeLibrary with the argument pipe_strategy=append
to use the result as the last argument by default.
You can find more examples in the /tests
directory.
My Test Case
Pipe Sum 1 2
... >> Subtract 4 $
... >> Should be Equal As Integers 1
In this example, $
is replaced with the result of Sum, so Subtract is called as Subtract 4 3
.
You can initialize the library with custom settings:
*** Settings ***
Library PipeLibrary pipe_strategy=append placeholder=$ pipe_operator=>>
Currently, PipeLibrary does not support keyword syntax highlighting and autocompletion in the Robot Framework environment. This is due to the dynamic nature of the pipe operator and the way arguments are passed between keywords.
Contributions to PipeLibrary are welcome! If you have suggestions for improvements or have identified a bug, please feel free to open an issue or submit a pull request on our GitHub repository.