Context
The context changes some configuration parameters while QualityMate is executing. That being said, a Context is a boundary in which QualityMate executes with a parameter-defined environment.
When to use
Add or change parameters to a portion of the code during a script execution.
How to use
UiConfigurationManager class can be used inside a
using
declaration to apply the parameters on a code block.ConfigurationContextAttribute can be used to load a
.runsettings
file on methods and classes.
UiConfigurationManager
The UiConfigurationManager
class is used to generate a new context with user-defined parameters to use in that context. Also, you can check the user-defined parameters through the GetSetting
method.
Using the UiPlayerConfiguration class
Define a UiPlayerConfiguration
that will hold the desired parameters of the context, for example:
UiPlayerConfiguration mySettings = new UiPlayerConfiguration
{
BusyLoaderSelectors = new[] { ".black-screen", ".black-element", },
StepTimeout = 10000,
};
Use the UiConfigurationManager's CreateContext()
inside a using
declaration to apply the dictionary parameters on the code block; a .runsettings
file path can be used instead.
using (controller.Configuration.CreateContext(mySettings))
{
// Code
}
Configuration Context Attribute
The ConfigurationContextAttribute can be used as metadata for classes and methods to define a .runsettings
file path. This attribute will be loaded at runtime by UiTest
and will apply the respective configuration.
Class attribute
[ConfigurationContext("MyPath/MySettings.runsettings")]
[TestClass]
public class MyClass : UiTest
{
// Class code
}
Method attribute
[ConfigurationContext("MyPath/MySettings.runsettings")]
[TestMethod]
public void MyMethod()
{
// Method code
}
Last updated
Was this helpful?