Adding Variable to global parameter

Ask general questions here.
chriszzoo
Posts: 6
Joined: Tue Nov 14, 2017 5:07 pm

Adding Variable to global parameter

Post by chriszzoo » Fri Dec 08, 2017 6:10 am

Hello,

I have the following problem...
I want to add different parameter as variable to my base URL which is a Global Parameter. The Goal is to add parameters to the url before starting the Open Browser action.

I tried something like this as User Code:

Public void (string args1)
{
URL=URL+VarURLParameter;
}

It works for the first test case with the global parameter URL...but within the second testcase it adds "VarURLParameter" again, that the URL looks more like this:

URL=URL+VarURLParameter+VarURLParameter


..for the third Test Case it opens the URL like this

URL=URL+VarURLParameter+VarURLParameter+VarURLParameter

...so on for 4th, 5th and 6th testcase

Maybe someone has a Solution or can help me? Can i reset the global parameter to the input value after the Open Browser action for TC1?

Best regards,

Chriszzoo
Last edited by chriszzoo on Fri Dec 08, 2017 8:46 am, edited 1 time in total.

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

Re: Adding Variable to global parameter

Post by odklizec » Fri Dec 08, 2017 8:45 am

Hi,

Could please post a sample solution showing the problem? I guess you need to use the global parameter somewhat differently. But it's hard to say without seeing exact implementation of the global parameter and usage of custom code. So please, create a small sample solution and share it with us. Thanks.
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

chriszzoo
Posts: 6
Joined: Tue Nov 14, 2017 5:07 pm

Re: Adding Variable to global parameter

Post by chriszzoo » Fri Dec 08, 2017 2:55 pm

Hi,

thanks for your answer.

I created a little test solution:

Test Suite Overview:
TestSuite.JPG

Data Binding TC1:
Data binding.JPG
Recording Module:
Recording_Module.JPG
User Code of recording module:

Code: Select all

namespace TestURL
{
    public partial class OpenURL
    {
        /// <summary>
        /// This method gets called right after the recording has been started.
        /// It can be used to execute recording specific initialization code.
        /// </summary>
        private void Init()
        {
            // Your recording specific initialization code goes here.
        }

        public void AddVariableURL()
        {
            
			URL=URL+VarURLParameter;
        }

    }
}
see next reply for more screenshots...
You do not have the required permissions to view the files attached to this post.

chriszzoo
Posts: 6
Joined: Tue Nov 14, 2017 5:07 pm

Re: Adding Variable to global parameter

Post by chriszzoo » Fri Dec 08, 2017 2:57 pm

When i open TestURL.exe through command line with parameter URL:

GIT Bash:
Git_bash.JPG
Test Results:
Test_Summary1.JPG
Test_Summary2.JPG
You see my problem?

Best regards,
Chriszzoo
You do not have the required permissions to view the files attached to this post.

chriszzoo
Posts: 6
Joined: Tue Nov 14, 2017 5:07 pm

Re: Adding Variable to global parameter

Post by chriszzoo » Fri Dec 08, 2017 2:59 pm

Data Connector TC1:
DataConnect_TC1.JPG
You do not have the required permissions to view the files attached to this post.

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

Re: Adding Variable to global parameter

Post by odklizec » Fri Dec 08, 2017 3:25 pm

Hi,

I see. I think the easiest solution is to not replace the URL variable with merged strings, like you do it in your code. You should use another variable for merged URL and VarURLParameter strings.

Simply create a new recording module variable in OpenURL module, e.g. called 'mergedURL'. Then use this new variable in OpenBrowser and Log actions. And in custom code use this:

Code: Select all

mergedURL=URL+VarURLParameter;
Hope this helps?
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

chriszzoo
Posts: 6
Joined: Tue Nov 14, 2017 5:07 pm

Re: Adding Variable to global parameter

Post by chriszzoo » Fri Dec 08, 2017 3:32 pm

odklizec wrote:Hi,

I see. I think the easiest solution is to not replace the URL variable with merged strings, like you do it in your code. You should use another variable for merged URL and VarURLParameter strings.

Simply create a new recording module variable in OpenURL module, e.g. called 'mergedURL'. Then use this new variable in OpenBrowser and Log actions. And in custom code use this:

Code: Select all

mergedURL=URL+VarURLParameter;
Hope this helps?

Thank you very much! Works now.. as simple as it is :shock: