Dynamically setting a Settings value from build commandline/buildargs

5 posts, 0 answers
  1. David
    David avatar
    45 posts
    Member since:
    Aug 2010

    Posted 20 Dec 2011 Link to this post

    Is there a way I can, at build time, pass a build argument to a Settings value? 

    For example, I would like to build my initialization tests to be prepared to test in any of our environments (prod, test, prodsupport). I would like to drive the location through Settings and/or through build arguments to launch the correct site and use the correct environment username/password combinations.
  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 20 Dec 2011 Link to this post

    Hello David,

    Our BaseURL feature is specifically designed to handle running the same test(s) in multiple environments. However it won't solve the problem if needing to use different username/passwords in the different environments. To handle that I recommend using a Data Driven test that feeds in the correct username/password. Just swap out the input file (e.g. Excel file) with the right file just before you execute your test.

    NOTE: Test Studio maintains a copy of your Excel file in the Data folder for the project. You need to swap out that file, not it's original location (e.g. My Documents).

    Greetings,
    Cody
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. David
    David avatar
    25 posts
    Member since:
    May 2012

    Posted 15 Aug 2012 Link to this post

    Hi Cody, this is a different David, but same question...

    The problem with setting the base url in the test list is it isn't constant and would need to be modified for each environment where the test would be run - in our case, this could be dozens (each team has their own automation running checking their work) and since it is automated, we would want to pull the tests from source control.  It is possible to automate the updating of the XML file, but awkward...

    It looks possible to set the baseurl from a coded step - we could read it from a file and set it in a coded step, but that also seems like a lot to ask of every test authored.

    Any other suggestions?

    Related question: I have read the articles on baseURL, but something I am missing is - what are the consequences if you don't use baseUrl?  Is it just the frame info that is affected?  Seems you might get around that issue by making sure the frame id can be used to find the frame.
  4. David
    David avatar
    45 posts
    Member since:
    Aug 2010

    Posted 15 Aug 2012 Link to this post

    David,
    I was able to solve this problem by doing the following (assuming you are using VisualStudio 2010 plug-in): 
    1. I create multiple testsettings files (Rapid, ProdSupport, Production)
    2. in each testsettings file, I set the BaseUrl field to my domain (i.e. https://rapid.testsite.com). BaseUrl is found in Test Settings > Telerik Test Studio > Web (tab) > Navigation > BaseUrl.

    From here you can use the commandline argument /testsettings in your mstest <buildargs> tag to drive the location of the tests to be run.

    For my tests I have every setup step, which always includes login, get the BaseUrl from ArtOfTest.WebAii.Core.Settings.Current.Web.BaseUrl. That then looks in to our user database to get the password for the requested user and logs in that user in the correct environment. Knowing which database to use depends on the subdomain of the BaseUrl which I strip out through code.

    You can replicate this process using an XML file but you would have an XML file for each environment.


    What I have found is that, though my recording settings are set to ignore the baseurl (Elements Page Compare Mode = "RelativePathOnly"), when recording modal and radwindows (and sometimes objects) the baseurl is still included in the object search definition. This does effect recording frame interaction causing me to have to go back and edit the lookup definition for every frame I record, even when recording it for the second time to edit a test. This may be a bug which I have not yet had time to report to Telerik.

    I hope this helps.
  5. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 20 Aug 2012 Link to this post

    Hi David Burns,

    I apologize for the delay getting back to you.

    In addition to David Adams recommendation, you can also data bind the Navigate To test step. Use an Excel file as the input. Now all you need to do is update (or replace) the Excel file with the URL to start the test at. You're right you could use code, but that might be overkill when you simply want to configure the starting URL.

    Yes, Frames can be an issue when dealing with BaseURL. Very often the website developer doesn't add ID to the <iframe> element. Then we try to find it according to the src attribute. If the URL changes we'll have a problem finding the right <iframe> because the URL in the src attribute will change.

    It's not a problem for all the other elements because Test Studio always looks for them on whatever is currently displayed in the browser. Thus no matter what the URL is (assuming the element is not in an <iframe> node) we'll find it as long as it there on the current page.

    Hope that helps. Let me know if I can be of any further assistance.

    Kind regards,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!