I created simple Coded UI test where I do the following:
After the UIMapping is generated I see a bunch of auto-generated mapping code. Within the UIMapping file (class) I see URL's which are essentially hard-coded.
Example:
this.FilterProperties[HtmlDocument.PropertyNames.PageUrl] = "http://mytesturl:8000";
this.mUIItem50006598Hyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Href] = "http://mytesturl:8000/link"
How can I make my automated UI tests configurable so that I can run the same tests against different environments (dev, test, prod...etc)?
As Adrian mentioned this is an oft-repeated question with no clear answer. You can find a little information on my approach HERE.
The short story is that you won't be able to dynamically configure an environment if you're relying on the CodedUI mapping functionality unless your test methods:
So your code will look like:
[TestMethod]
public static void GenericTestMethod() {
//get browserWindow from your test setup method etc.
GoToEnvironmentBaseUrl(browserWindow);
MapperGeneratedCodedUiMethod();
AssertStuff();
}
public static void GoToEnvironmentBaseUrl(BrowserWindow browserWindow) {
browserWindow.NavigateToUrl(new Uri("http://www."
+ ConfigurationManager.AppSettings.Get("EnvironmentURLMod")
+ ".com"));
}