How the Telerik Testing Framework behaves during a test run is controlled by the settings contained in the Settings object. There are many settings you can take advantage of to modify its behavior to better meet your testing requirements or testing environment. The complete list of settings is detailed in the table below. A few of the more commonly used settings include:
BaseUrl - Sets the base URL used by the NavigateTo command.
DefaultBrowser - Controls which browser will be started by the LaunchNewBrowser command.
EnableSilverlight - If you will be doing any Silverlight application settings, this must be set to True.
There are a few methods of controlling the settings in the Settings object. Which method you use depends on when and how you want them set in your unit test.
If you're not using one of Telerik's test templates (VsUnit, NUnit, MbUnit, xUnit) to create your unit test, you'll need to create your own Settings object and then pass that object as a parameter to the constructor of your Manager object. For example:
// Create my own Settings object and then modify the defaults
Settings mySettings = new Settings();
mySettings.DefaultBrowser = BrowserType.FireFox;
mySettings.ClientReadyTimeout = 60000;
// Use my Settings object to construct my Manager object
Manager myManager = new Manager(mySettings);
' Create my own Settings object and then modify the defaults
Dim mySettings As New Settings()
mySettings.DefaultBrowser = BrowserType.FireFox
mySettings.ClientReadyTimeout = 60000
' Use my Settings object to construct my Manager object
Dim myManager As New Manager(mySettings)
If you're using one of Telerik's test templates (VsUnit, NUnit, MbUnit, xUnit) to create your unit test, you'll need to create your own Settings object in the TestInitialize section (or Setup section if you're using NUnit) and then pass that object as a parameter to the Initialize method of the base class. For example:
// This will get a new Settings object. If a configuration
// section exists, then settings from that section will be
Settings settings = GetSettings();
// Override the settings you want. For example:
settings.UseHttpProxy = true;
// Now call Initialize again with your updated settings object
Initialize(settings, new TestContextWriteLine(this.TestContext.WriteLine));
' This will get a new Settings object. If a configuration
' section exists, then settings from that section will be
Dim settings As Settings = GetSettings()
' Override the settings you want. For example:
settings.UseHttpProxy = True
' Now call Initialize again with your updated settings object
Initialize(settings, New TestContextWriteLine(AddressOf Me.TestContext.WriteLine))
Note: Be sure to call Initialize only once. Calling Initialize a second time will simply be ignored and you'll be left wondering why your settings did not take effect.
Lastly you can modify most of the settings after your test is already initialized and under-way. Here's how you to do that:
Manager.Settings.AnnotateExecution = true;
Manager.Settings.DefaultBrowser = BrowserType.FireFox;
Manager.Settings.AnnotateExecution = True
Manager.Settings.DefaultBrowser = BrowserType.FireFox
Note: The following settings can only be set during initialization: AspNetDevServerPort, CreateLogFile, EnableUILessRequestViewing, LocalWebServer, LogLocation, VerboseHttpProxy and WebAppPhysicalPath.
The RecycleBrowser feature was added in version 2.0. Using it can significantly speed up running an entire test suite, no more starting and shutting down of the browser for each individual unit test. It works by launching one browser window in the test fixture initialization of your test suite and then constantly reusing that same browser window for all unit tests contained in your test suite.
There are a just a couple of things you need to be aware of to properly use the RecycleBrowser feature:
1. When RecycleBrowser is active, any Manager.LaunchNewBrowser or Browser.Close() calls will be ignored.
2. You must call the base classes ShutDown() method in the test fixture teardown section to properly the browser window at the end of the test suite. If you miss this then browser windows will be left behind after your test suite has finished and exited.
If it ever becomes necessary you can restore all the settings (except for those that can only be set during initialization) back to their default values. Just use the Reset() method of the Settings object. For example:
This table lists all of the WebAii framework settings that are available for you to use:
|Controls whether or not to highlight/annotate the target elements that the requested action is being executed against. e.g. Actions.Click(goButton);
|This read-only setting contains the full physical path to your local ASP.NET development web server (WebDev.WebServer.EXE). It is set by the framework when LocalWebServer is set to "AspNetDevelopmentServer". Otherwise it is an empty string.
|Controls the AspNetDevServer (if used) port. If this is not set (-1) a random port will be generated each time the manager is created.
|0 to int.MaxValue
|Sets the base URL to use for all NavigateTo() commands. When set NavigateTo() should use a relative URL (e.g. "~/default.aspx").
|Any valid URL
|Timeout used to wait for a client (a browser) to be ready after it is first launched or after executing a command (in milliseconds). For example after launching the browser if the browser is not ready within this timeout the framework will throw a TimeoutException.
|0 to int.MaxValue
|Gets or sets whether to create a log file on disk. This value is read once at initialization time. Changing this value during test execution has no effect.
|The default browser (i.e. Internet Explorer or Firefox or AspNetHost) to launch when calling Manager.LaunchNewBrowser().
|Controls whether or not Silverlight test automation is enabled.
|Controls whether or not to allow debugging of UILess page requests using a UI browser like Internet Explorer.
|The amount of time to wait for a response to be received from the browser (in milliseconds) after sending it a command request. For example: if there is no response from the browser within this amount of time after sending it a click request, the framework will throw a TimeoutException.
|0 to int.MaxValue
|Sets the amount of execution delay (in milliseconds) between commands. This can help in observing test execution.
|0 to int.MaxValue
|Used internally by Automation Design Canvas only.
|This read-only setting indicates whether or not the currently logged on user is an interactive user. Normally this will always be true unless you are logged in under a non-interactive account. For example, if you create another account on your machine and from your current account launch a process using that other account without interactively logging into that account. That is when this property will be set to false. This is a common scenario when performing continuous integration within a build system and running tests. Usually there is a machine that has an account that VisualStudio simply uses to logon the machine non-interactively, build a product and launch tests.
|Depends on run time environment.
|Gets or sets whether to make sure the browser process is killed when closing the browser. Note: Firefox is a single process browser. If you are using multiple browser instances and this setting is on, it will kill all open instances of Firefox.
|Controls whether or not to use the local ASP.NET development server. When set to true, be sure to set WebAppPhysicalPath to the full physical path of the root of your ASP.NET development server.
|Controls whether to log annotations to the log file.
|Location where all logging will be performed, both captured bitmaps and WebAii's log file.
|Any valid URI.
|Controls whether or not the Manager object will query Windows Application Event log on exit for any error logged from automation clients. Any errors will be logged to the test log.
|When set to true, one instance of the browser will be launched and recycled through out the entire test class and tests until Manager.Dispose is called.
|Sets the simulated mouse move speed for Desktop.Mouse.Move()/DragDrop() operations in pixels/millisecond. Typically values are between 0.1f - 0.5f.
|0 to Single.MaxValue
|Gets/Sets whether to use the built-in http proxy during automation. NOTE: will be forced to true when EnableSilverlight is set to true.
|Gets/Sets whether the HTTP proxy produces lots of tracing output.
|Controls the rate that the condition is tested by the HtmlWait class. This value specifies the number of milliseconds to wait between tests of the condition.
|1 to int.MaxValue
|This setting is used when LocalWebServer is set to 'AspNetDevelopmentServer'. It must be the full physical path to the web application root that you are testing or a path relative to the location of the .config file.
|The full physical path to the web application root.