Silk Test Workbench does not contain a date / date time data type, we can however use a Workbench .Net script to manipulate the value of a date or time value. The following steps will demonstrate how to store a date value from your application to a variable in a Workbench Visual test and pass the data to a Workbench .Net script for processing. Once the date value has been manipulated it can be passed back to the Workbench Visual test. The steps below cover how to pass data to the .Net script. Preparing the Visual Test 1) Within a Visual Test, click Insert - Variable - Add Local 2) Provide the variable with a name and click ‘OK’ button, on this instance it was given the name lvSelectedDate 3) Enter a date value such as '16/05/2014' 4) Click 'OK' Button Modifying the .Net script 1) With the .Net script open, navigate to the properties panel on the left and perform a right click on the parameters item and select ‘Add input parameter’ 2) Enter the name lvSelectedDate and ensure that the value of the 'type' dropdown is ‘String’ 3) Click ‘OK’ 4) Repeat steps 3 - 5 to ‘Add output parameter’ and Enter the name lvNewDate for output variable 5) Alter the Main() method to include the parameters required for passing parameters to and from Visual tests and .Net scripts. Public Sub Main(args As IDictionary( Of String , Object )) For more information please see the Silk Test Help Topic ' Defining Parameters to Pass Between a Visual Test and a Script ' 6) Declare two date variables within the .Net script, one variable to store the date time value of lvSelectedDate and another to store the value to be output to the Visual Test. 7) Perform a conversion on the input parameter vSelectedDate to be of data type ‘Date’ 8) Get the previous days date by subtracting a day from variable dCurrentDate 9) Convert the value of the variable 'dYesterDate' to a string, this string value can then be assigned to an output variable to be passed to the visual test. 10) Save the script Add .Net Script to Visual Test 1) Navigate to the Visual Test and Click the test step where you wish the .Net script to be inserted below. 2) Perform a right click and select Insert - .Net script 3) Select the appropriate .net script and click ‘OK’ 4) Navigate to the properties section of the newly added test step. 5) Select the variable to be passed to the input parameter of the .Net script by clicking the associated ellipses button 6) Select the Variable that is storing the value of the date, in this instance it is lvSelectedDate and Click OK 7) Repeat steps 6 + 7 to assign a variable to the output parameter of the .Net script. 8) The script is now setup and ready for playback or available for you to make use of the output parameter from the .Net Script.
↧