Created By  alexey.grinevich Thursday, August 2, 2018

Sometimes test set requires a value passing through the sequence of test cases. Good example is User ID assigned during sign it and then used in subsequent test cases.

Another use case is when test case requires some input value that should always be unique.

Store Value Across Sessions

Rapise includes API simplifying reading and storing of values between sessions:

  • Global.GetProperty('Propname', defValue) -- Read property value from %WORKDIR%\Config.json. See online help.

  • Global.SetProperty('PropName', value)-- Set property value to %WORKDIR%\Config.json. If the file does not exist it will be created. See online help.

Incrementing

Here is a sample function. Every time it is called the value is incremented by 1 and new value is returned as a string INV-nnn, where nnn is a new number.

function GlobalIncrementInvoiceNo()
{
    // Read invoice number (or 100 if no previous number set yet)
    var invoiceNo = Global.GetProperty('InvoiceNo', 100)
    // Increment value by 1
    invoiceNo++;
    // Store it for next use
    Global.SetProperty('InvoiceNo', invoiceNo)
    // Make final string like 'INV-123'
    return 'INV-'+invoiceNo;
}

You may put this function into Functions (<testname>.user.js) file.

Calling from RVL

Once function is defined in the .user.js it may be called from RVL using the Functions object (all global functions are shown as methods for this object).

Working Example

You may download and this sample test.

Attachments

Selected files will be attached to any email sent on saving ticket.

file selected files selected  () Delete Selected

  • Created:
  • by:

Select files to upload

Or drag and drop files here

Uploading …
Done!
Upload More?
There was an error.
Try again?

Save to upload the selected file(s)

Article Info
  • Last Updated: 8/2/2018
  • Article ID: KB367
  • Views: 3427