Set BaseURL in the code. How?

11 posts, 2 answers
  1. Konstantin
    Konstantin avatar
    11 posts
    Member since:
    Oct 2012

    Posted 12 Mar 2013 Link to this post

    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
  2. Answer
    Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 15 Mar 2013 Link to this post

    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
  3. Konstantin
    Konstantin avatar
    11 posts
    Member since:
    Oct 2012

    Posted 18 Mar 2013 Link to this post

    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
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 18 Mar 2013 Link to this post

    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
  5. Konstantin
    Konstantin avatar
    11 posts
    Member since:
    Oct 2012

    Posted 18 Mar 2013 Link to this post

    -- 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["..."]
  6. Answer
    Cody
    Admin
    Cody avatar
    3360 posts

    Posted 18 Mar 2013 Link to this post

    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
  7. Tim
    Tim avatar
    5 posts
    Member since:
    Oct 2013

    Posted 19 Dec 2013 Link to this post

    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
  8. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 20 Dec 2013 Link to this post

    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!
  9. Tim
    Tim avatar
    5 posts
    Member since:
    Oct 2013

    Posted 20 Dec 2013 Link to this post

    Thank you Cody!
  10. Gavin
    Gavin avatar
    5 posts
    Member since:
    Mar 2013

    Posted 20 May in reply to Cody Link to this post

    Another busted link...
  11. Boyan Boev
    Admin
    Boyan Boev avatar
    1040 posts

    Posted 25 May Link to this post

    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!
Back to Top