Hi,
Is it possible to pass a variable in a recording module to a user code method as parameter.
I basically wanted to create a custom GetValue method and store the value in an existing or newly created variable.
Regards
Chris
Pass module variable as User Code parameter
Re: Pass module variable as User Code parameter
Any ideas on this matter?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Pass module variable as User Code parameter
Hi Chris,
Yes, this is of course possible.
The following two sections of our UserGuide should provide some useful information: Lesson 3: Data-Driven Testing and User Code Actions and Parameters.
If this shouldn't prove helpful, please describe in more detail what you are trying to do.
Regards,
Markus
Yes, this is of course possible.
The following two sections of our UserGuide should provide some useful information: Lesson 3: Data-Driven Testing and User Code Actions and Parameters.
If this shouldn't prove helpful, please describe in more detail what you are trying to do.
Regards,
Markus
Re: Pass module variable as User Code parameter
Hi Markus,
I've used the same method as in lesson 5 under section "User Code Actions and Parameters".
Now I do see that my variable is bound to my user code argument but I'm not able to change it's value.
The value of the variable that is.
Furthermore, I constantly get the warning that my module variable is not bound to a data column.
More in detail, I'm trying to create a method that reads a certain value from a table based on some criteria passed via the arguments (basically x and y coordinates) and store it in the Recording Module variable.
On a side note. I also tried running the the test suite instead of the action.
Without any luck however.
I've used the same method as in lesson 5 under section "User Code Actions and Parameters".
Now I do see that my variable is bound to my user code argument but I'm not able to change it's value.
The value of the variable that is.
Furthermore, I constantly get the warning that my module variable is not bound to a data column.
More in detail, I'm trying to create a method that reads a certain value from a table based on some criteria passed via the arguments (basically x and y coordinates) and store it in the Recording Module variable.
On a side note. I also tried running the the test suite instead of the action.
Without any luck however.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Pass module variable as User Code parameter
Hi Chris,
What you are trying to do is easily possible. Each module variable is simply a .Net property which can be accessed via code and in the action table.
So you can just access the variable in code to set it to the specific value,or you can bind it to a data source as described in Lesson 3: Data-Driven Testing to change the value of the variable to the value of a specific column of your data source.
Regards,
Markus
What you are trying to do is easily possible. Each module variable is simply a .Net property which can be accessed via code and in the action table.
So you can just access the variable in code to set it to the specific value,or you can bind it to a data source as described in Lesson 3: Data-Driven Testing to change the value of the variable to the value of a specific column of your data source.
Regards,
Markus
Re: Pass module variable as User Code parameter
Hi there,
I appreciate your help but I think I might have to be more specific
I am merely creating user code actions to be used by somebody else (the tester). So I don't know in advance which variables are going to be used. That is why I wanted to bind the variables to one of my parameters, such that when the tester creates a new variable it will be bound to my parameter and I can set it via my parameter.
Sort of like a two way bind if you will.
I appreciate your help but I think I might have to be more specific
I am merely creating user code actions to be used by somebody else (the tester). So I don't know in advance which variables are going to be used. That is why I wanted to bind the variables to one of my parameters, such that when the tester creates a new variable it will be bound to my parameter and I can set it via my parameter.
Sort of like a two way bind if you will.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Pass module variable as User Code parameter
Hi Chris,
I am very sorry but I don't get the problem , when you just want to bind a module variable to a global or test case parameter you can easily do this by opening the Data Binding tab of the TestCase's properties window as shown below to bind it: To change the value of the module variable you need to change the value of the parameter to which the module variable is bound, this value can also be set via a command line argument.
Regards,
Markus
I am very sorry but I don't get the problem , when you just want to bind a module variable to a global or test case parameter you can easily do this by opening the Data Binding tab of the TestCase's properties window as shown below to bind it: To change the value of the module variable you need to change the value of the parameter to which the module variable is bound, this value can also be set via a command line argument.
Regards,
Markus
You do not have the required permissions to view the files attached to this post.
Re: Pass module variable as User Code parameter
Hi Markus,
Now I get your thinking.
I'm sorry I might have expressed myself wrongly.
While in a Recording Module in User Code, I define my method which the tester (not me) then uses as Action in the Recording module interface (Recording.rxrec) and provides arguments for my method.
Because I need to implement this as generically as possible, I don't have any knowledge about the module variables the tester creates or uses.
That is also the reason why I can't perform any other manipulation whatsoever (like binding to a parameter like you showed).
Here are 3 scenarios I could work with:
Here's a little sample from the testers point of view
Hope this clarifies my problem a little better
Regards,
Chris
Now I get your thinking.
I'm sorry I might have expressed myself wrongly.
While in a Recording Module in User Code, I define my method which the tester (not me) then uses as Action in the Recording module interface (Recording.rxrec) and provides arguments for my method.
Because I need to implement this as generically as possible, I don't have any knowledge about the module variables the tester creates or uses.
That is also the reason why I can't perform any other manipulation whatsoever (like binding to a parameter like you showed).
Here are 3 scenarios I could work with:
public void GetValueFromTable(int x, int y, ref string variable, Adapter repoItem) { //do Something //directly pass the referenced variable and operate on it }
public void GetValueFromTable(int x, int y, string nameOfTheModuleVariable, Adapter repoItem) { //do Something //retrieve the module variable through reflection thanks to nameOfTheModuleVariable }
public void GetValueFromTable(int x, int y, string boundVariable, Adapter repoItem) { // do Something // change the value of the Module variable by changing the boundVariable }I noticed that when I create a new UserCode Action in the Recording and provide a variable as argument for the method, the module variable is bound but this binding seems to only work in one direction. The value of the module variable is correctly passed to my method but I also want it to work the other way around without directly calling the module variable.
Here's a little sample from the testers point of view
Hope this clarifies my problem a little better
Regards,
Chris
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Pass module variable as User Code parameter
Hi Chris,
Thanks for describing this issue in more detail, now I got it .
It is unfortunately not possible to add parameters by reference with a Ranorex recording. This was also discussed in this thread: how can i pass a value from a procedure to actions table?.
So you could use the second or third approach, or the way described in the other thread.
Regards,
Markus
Thanks for describing this issue in more detail, now I got it .
It is unfortunately not possible to add parameters by reference with a Ranorex recording. This was also discussed in this thread: how can i pass a value from a procedure to actions table?.
So you could use the second or third approach, or the way described in the other thread.
Regards,
Markus