This is a migrated thread and some comments may be shown as answers.

Set BaseURL in the code. How?

10 Answers 434 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Konstantin
Top achievements
Rank 1
Konstantin asked on 12 Mar 2013, 07:49 PM
I need to utilize BaseURL feature during playback, but instead of the actual BaseURL coming from any sort of test configuration I want to be able to calculate it in the code and stick the value to the test run for all subsequent test steps to use. Can I do that?

Or, otherwise, can I set BaseURL to use for playback in the data source (XML file) the test is bound to?

Thank you!
Konstantin

10 Answers, 1 is accepted

Sort by
1
Accepted
Plamen
Telerik team
answered on 15 Mar 2013, 09:50 AM
Hello Konstantin,

You can override the BaseUrl property in a coded step like this:
Manager.Settings.Web.BaseUrl = "http://www.BaseUrl.com/";


Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Konstantin
Top achievements
Rank 1
answered on 18 Mar 2013, 05:16 PM
One thing I figured on my own is how to set BaseUrl from the data:

string baseUrl = Data["BaseUrl"].ToString();
Manager.Settings.Web.BaseUrl = baseUrl;

The part
    Data["BaseUrl"]
is absolutely not documented and is terribly hard to discover. Please update the documentation for data binding.

Thank you!
Konstantin
0
Cody
Telerik team
answered on 18 Mar 2013, 06:19 PM
Hi Konstantin,

Data["BaseUrl"] will only work if you're running a data driven test and your data source includes a column named "BaseUrl". Otherwise you'll get this error:

System.ArgumentException: The extracted variable 'BaseUrl' does not exist in the store.

Greetings,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Konstantin
Top achievements
Rank 1
answered on 18 Mar 2013, 06:29 PM
-- Data["BaseUrl"] will only work if you're running a data driven test and your data source includes a column named "BaseUrl".

Yes, of course! But it is exactly our scenario and it was impossible to discover that solution from documentation. Documentation never ever says anything about Data["..."]
0
Accepted
Cody
Telerik team
answered on 19 Mar 2013, 01:28 AM
Hi Konstantin,

We do have this documentation page specifically for using Data in code. There are many other code samples there as well.

Greetings,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tim
Top achievements
Rank 1
answered on 19 Dec 2013, 10:15 PM
Plamen,

When you override the BaseUrl using the coded step method you mentioned:
Manager.Settings.Web.BaseUrl = "http://www.BaseUrl.com/";

does this only override the BaseUrl for this coded step? Or maybe does it override the BaseUrl for the rest of this test?

Thank you,

Tim
0
Cody
Telerik team
answered on 20 Dec 2013, 02:51 PM
Hi Tim,

That line of code changes the global setting for the life of that one test. So yes it's for all steps, coded and non-coded from that point forward up until the particular test ends. Once the test ends, this in memory settings object is discarded.

Regards,
Cody
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Tim
Top achievements
Rank 1
answered on 20 Dec 2013, 02:55 PM
Thank you Cody!
0
Gavin
Top achievements
Rank 1
answered on 20 May 2016, 11:13 PM
Another busted link...
0
Boyan Boev
Telerik team
answered on 25 May 2016, 01:45 PM
Hello Gavin,

Please excuse us of the wrong link.

Here is the correct one.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Konstantin
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Konstantin
Top achievements
Rank 1
Cody
Telerik team
Tim
Top achievements
Rank 1
Gavin
Top achievements
Rank 1
Boyan Boev
Telerik team
Share this question
or