Keyword Configuration
Step offers holistic business use cases that lets business and technical users reuse different automation components. To enhance interaction quality and prevent input mismatches, users can specify mandatory information required to execute a specific Keyword.
Schema
Optional and mandatory input keys can be specified in the form of a JSON schema tied to the Keyword. Schema can be provided manually as part of the Keyword’s generic fields or automatically populated based on the “schema” attribute of the Keyword annotation in Java and .NET.
@Keyword(name = "keywordName", schema = "{ \"properties\": { \"myInputKey\": { \"type\": \"string\"}}, \"required\" : [\"myInputKey\"]}")
public void myKeyword() throws Exception {
[...]
}
[Keyword(name = "keywordName",schema = @" { 'properties': { 'myInputKey': { 'type': 'string'}}, 'required' : ['myInputKey']}")]
public void MyKeyword()
{
[...]
}
Unsupported as of 3.11.0
Properties
Keywords may require access to specific properties, that are not directly related to business inputs.. These properties can originate from the local agent’s configuration, the controller’s central configuration, dynamic parameter sets within the plan, or the central parameter view.
Required properties
Users can specify a list of required properties using the Keyword annotation in Java, .NET, and JavaScript.
@Keyword(name = "keywordName", properties = {"myProperty"})
public void myKeyword() throws Exception {
[...]
}
[Keyword(name = "keywordName", properties = new String[] { "myProperty" })]
public void MyKeyword()
{
[...]
}
Unsupported as of 3.11.0
Enable validation
Please note that the required properties are only checked if the following properties in your step.properties file are set to true for Java and .NET keywords, respectively:
- plugins.java.validate.properties=true
- plugins.dotnet.validate.properties=true
When enabled, if any of the defined properties are missing, the Keyword execution will fail.
Remark: enabling validation is only possible if your Keywords use the Step API version 1.1.0 or above.
Optional properties
If you wish to validate properties while still allowing access to optional properties, you can define them separately using the following annotation:
@Keyword(name = "keywordName", optionalProperties= {"optionalProp","optionalProp2"})
public void myKeyword() throws Exception {
[...]
}
[Keyword(name = "keywordName", optionalProperties = new String[] { "optionalProp" })]
public void MyKeyword()
{
[...]
}
Unsupported as of 3.11.0
Using dynamic properties
You may also need to validate dynamic properties, which are dependent on other properties. For example:
app.user.name=myName
app.user.myName.pwd=myPwd
You can define dynamic properties in the required properties annotation with a placeholder as follows:
"app.user.{app.user.name}.pwd"