Assigning values in variables for called test cases

Hi All!

Here’s my situation.

TC1: Basic Login Script
url
username
password

TC2: Navigate
Call “TC1” {while assigning values to variables: url, username, password}
(preferably from the KS database)

Thank you very much!

Create a Variables in the Variables tab and then call the TC1 TC1.

2018-11-30_2053.png

1 Like

Yes, you can do that by using

WebUI.callTestCase(findTestCase(‘YOUR/TEST/CASE/PATH’),[“url” : url, “username” : username, “password” : password], FailureHandling…)

This way, you can use the variable specified in TC2 in TC1, however this makes TC1 dependant to TC2 (which means that TC1 might create error when run alone)

You can use variable url, username, password in TC1.

Ps. The value in TC1 looks like it’s not declared, but if you run the test cases from TC2, it will works.

2 Likes

Hansen William

In fact, the variables has to be declared as local variables (the variables tab) in TC1 in order to be able to call it from TC2 with parameters.

And can have some default values, when running TC1 standalone will just use the defaults.

Calling it from TC2, there are two options here:

- private variables (defined in the script) mapped to the TC1 call as in your example (or passed directly as values, e.g [“url” : ‘urlValueHere’, “username” : ‘usernameValueHere’, “password” : ‘passwordValueHere’])

- TC2 can have also own local variables, mapped to the TC1 call (and again can have some defaults values, which will substitute the TC1 defaults). By this way, if TC2 is also parametrized, his variables set can be further binded to a test data in a test suite (or grabbed from a data set using findTestData() … if has to be initialized as private variables )

to understand variables visibility, this can help:

1 Like

Hansen William said:

This way, you can use the variable specified in TC2 in TC1, however this makes TC1 dependant to TC2 (which means that TC1 might create error when run alone)

This is true. My plan is to create generic/general scripts which I can use as components to complete bigger test cases. What I wanted to do is parameterize the variables I can use.