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

Dynamically setting a Settings value from build commandline/buildargs

4 Answers 77 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 20 Dec 2011, 05:46 PM
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.

4 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 20 Dec 2011, 09:17 PM
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.
0
David
Top achievements
Rank 1
answered on 15 Aug 2012, 11:23 AM
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.
0
David
Top achievements
Rank 1
answered on 15 Aug 2012, 02:31 PM
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.
0
Cody
Telerik team
answered on 20 Aug 2012, 07:15 PM
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
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Cody
Telerik team
David
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or