Page 1 of 1

Changing the value of a variable within a code module

Posted: Thu Jan 24, 2019 1:08 pm
by seller_basti
Hello,

In my test case I want to register several users to a website. Each user is given its own UserId.
For the UserId I created a variable. The value that is assigned to the variable has following form: "UserId+Number" for example " UserId5".
I want to create a code modul to make sure that the UserId that I want to register is not already in use. To realize that I search for the UserId in the user pool.
If the UserId is already in use the the Number should be increased one step.
For example: If UserId5 is in use: UserId5 -> UserId6.
I already created a user code module which takes the value and increases the number. Now I want to know if it's possible to assign the new value to the variable, so that in the following modules, the new value is used.

My question now is:
How can I change the value of a varialbe within a code module.

Re: Changing the value of a variable within a code module

Posted: Fri Jan 25, 2019 12:24 pm
by odklizec
Hi,

I think the best way is to create a parameter (at test suite/test case level), and then create a variable of the same name in code/recording module of your choice. Then simply bind the variable from code/recording module to the parameter. This will assure the variable will get inside to code module and after its change, you can use the changed value in another module. The whole process of sharing data between modules is very well described here:
https://www.ranorex.com/blog/sharing-da ... o-another/