Sometimes, it is easier to write up a simple function with the help of a programming language than implement the same functionality with the help of the keywords in the Keyword Tests.
In this recipe we will consider how to call an ordinary function from the Keyword Test.
Create the following function in the module of Unit1:
function testRunFromKeywordTest(param1) { Log.Message("Parameter: " + param1); }
To evoke the function, it is necessary to do the following actions:
If the test should be launched, the log would contain the following message: Parameter: test string.
With the help of the Run Script Routine operation, we can call any function from the current project.
If it's necessary to call the function from a different project, we must add the respective module to the current project by beforehand right-clicking on the Script element, and navigating to Add | Existing Item menu item.
Besides calling the ordinary functions, Keyword Tests allow us to call code snippets, without creating individual functions (the Run Code Snippet operation), as well as the methods of screen objects (the Call Object Method operation). It is also possible to call other Keyword Tests by using the Run Keyword Test action from the Test Action group.
If you want to use values calculated earlier as parameters, you can use Project variables or Script variables to store the value and then specify it by clicking on the button with three dots next to the Value field.
3.144.232.189