Changing the value of a variable within a code module

Ranorex Studio, Spy, Recorder, and Driver.
seller_basti
Posts: 1
Joined: Tue Jan 08, 2019 3:51 pm

Changing the value of a variable within a code module

Post by seller_basti » Thu Jan 24, 2019 1:08 pm

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Fri Jan 25, 2019 12:24 pm

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/
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration