Using Global Parameters with a URL

Ranorex Spy, Recorder, and Studio.
AccidentReport
Posts: 76
Joined: Tue Dec 04, 2012 2:30 pm

Using Global Parameters with a URL

Post by AccidentReport » Mon Nov 04, 2013 10:17 am

I am currently building tests to test our web application. At present the tests are only running on my box and connecting to my server but we will shortly need to move them to test on multiple servers. All these servers run the same application but slightly different versions or hardware specs to test different aspects.

I've already modified the repository to use a variable for the top level DOM thanks to some help (http://www.ranorex.com/forum/posting.ph ... 16&p=21655). This means I can easily set or pass the value into the tests so that Ranorex can find the items on each box.

Now I want to update the step inside the test which opens the website. At present i have a step to open the browser with the following URL:

https://testappserver1/app/login/login.aspx

What I want is to use the global parameter I've got within this URL. Something like:

https://$testDomain/app/login/login.aspx

where $testDomain is set to 'testappserver1'.

Is this possible to do as I can't work it out?

Thanks in advance!

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Using Global Parameters with a URL

Post by krstcs » Mon Nov 04, 2013 2:33 pm

The easiest way would be the following:
1. Create a recording.
2. Add an "Open Browser" action using the actual URL as the target (you will change this in a min.).
3. Right-click the "Open Browser" action and select "Convert to User Code".
4. Right-click the "User Code" action you just created, and select "View code".
5. Change the method call from

Code: Select all

Host.Local.OpenBrowser("https://testappserver1/app/login/login.aspx", "IE", "", false, false);
to

Code: Select all

Host.Local.OpenBrowser("https://" + $testdomain + "/app/login/login.aspx", "IE", "", false, false);
You can also pass the browser as a parameter if needed.
Shortcuts usually aren't...

AccidentReport
Posts: 76
Joined: Tue Dec 04, 2012 2:30 pm

Re: Using Global Parameters with a URL

Post by AccidentReport » Mon Nov 04, 2013 2:56 pm

Brilliant! I knew they'd be a way. I'm just trying to do too many things at once and couldn't work it out. You're a star!