ClassAutomationDescriptor
This class represents the base class for all supported descriptors by this framework
Definition
Namespace:ArtOfTest.Common.Design.Extensibility.Descriptors
Assembly:ArtOfTest.WebAii.Design.dll
Syntax:
[DataContract(Namespace = "http://artoftest.com/schemas/WebAiiDesignCanvas/1.0.0")]
[KnownType(typeof(DescriptorConstraints))]
[KnownType(typeof(DataBoundObject))]
public abstract class AutomationDescriptor : DataBoundObject, INotifyPropertyChanged, ICustomTypeDescriptor, IExtensibleDataObject
Inheritance: objectDataBoundObjectAutomationDescriptor
Derived Classes:
Implements:
Inherited Members
Constructors
AutomationDescriptor()
Empty Constructor for serialization
Declaration
public AutomationDescriptor()
AutomationDescriptor(ITargetElement)
Initialize a new descriptor using the primary key
Declaration
public AutomationDescriptor(ITargetElement target)
Parameters
target
AutomationDescriptor(string, ITargetElement)
Initialize a new action object using the target
Declaration
public AutomationDescriptor(string name, ITargetElement target)
Parameters
name
target
Fields
_dataBindingExpressions
The list of data binding expressions for this descriptors properties.
Declaration
[CLSCompliant(false)]
protected Dictionary<string, string> _dataBindingExpressions
Field Value
_dynamicReadOnlyProperties
Dynamic read-only properties used to configure the display of properties in the properties window.
Declaration
[CLSCompliant(false)]
protected Dictionary<string, bool> _dynamicReadOnlyProperties
Field Value
_dynamicVisibilityProperties
Properties used to configure the display of the properties in the properties window.
Declaration
[CLSCompliant(false)]
protected Dictionary<string, bool> _dynamicVisibilityProperties
Field Value
_editorType
The editor UI associated with this descriptor
_elementDescriptors
The list of descriptors of the elements contained in this.Targets. This is the only structure that will get serialized as part of the descriptor de-serialization.
Declaration
[CLSCompliant(false)]
protected Dictionary<string, ElementDescriptor> _elementDescriptors
Field Value
_hasQuickTask
Whether the descriptor support a quick task or not
_pauseType
Whether to pause execution
Declaration
[CLSCompliant(false)]
protected StepPauseType _pauseType
Field Value
_quickTasks
The quick task if supported.
Declaration
[CLSCompliant(false)]
protected IQuickTasks _quickTasks
Field Value
_searchByImageFirst
Wait for all elements to exist first
Declaration
[CLSCompliant(false)]
protected SearchElementOrderType _searchByImageFirst
Field Value
_targets
The target descriptor objects that this action is targeting.
Declaration
[CLSCompliant(false)]
protected Dictionary<string, ITargetElement> _targets
Field Value
_testMethod
Gets the codeDom test method
Declaration
[CLSCompliant(false)]
protected CodeMemberMethod _testMethod
Field Value
_type
The descriptor type
Declaration
[CLSCompliant(false)]
protected AutomationDescriptorType _type
Field Value
_waitOnElementsExistFirst
Wait for all elements to exist first
Declaration
[CLSCompliant(false)]
protected bool _waitOnElementsExistFirst
Field Value
_waitOnElementsExistTimeout
The default time out to wait for
Declaration
[CLSCompliant(false)]
protected int _waitOnElementsExistTimeout
Field Value
Properties
CodeGenMode
Mode for code generation
Declaration
[Browsable(false)]
protected CodeGenMode CodeGenMode { get; set; }
Property Value
Constraints
Declaration
[DataMember(Name = "Constraints")]
[Browsable(false)]
public DescriptorConstraints Constraints { get; }
Property Value
CustomOrFriendlyDescription
Declaration
[Browsable(false)]
public string CustomOrFriendlyDescription { get; }
Property Value
DataBindingExpressions
Gets or sets the data binding expressions for this descriptor.
Declaration
[Browsable(true)]
[PrimaryProperty]
[DataMember(Name = "DataBindingExpressions")]
public Dictionary<string, string> DataBindingExpressions { get; set; }
Property Value
DescriptorType
Declaration
[Browsable(false)]
public string DescriptorType { get; }
Property Value
DontUseDomState
Flag to indicate whether descriptor uses a DOM state
Declaration
[Browsable(false)]
public virtual bool DontUseDomState { get; }
Property Value
DynamicReadOnlyProperties
Gets the dynamic read only properties of this descriptor
Declaration
[Browsable(false)]
public Dictionary<string, bool> DynamicReadOnlyProperties { get; }
Property Value
DynamicVisibilityProperties
Gets the visible properties of this descriptor
Declaration
[Browsable(false)]
public Dictionary<string, bool> DynamicVisibilityProperties { get; }
Property Value
EditorType
Gets or sets the editor type associated with this descriptor
Declaration
[Browsable(false)]
public Type EditorType { get; set; }
Property Value
EditorTypeString
Declaration
[Browsable(false)]
[DataMember(Name = "EditorType")]
public string EditorTypeString { get; set; }
Property Value
ElementDescriptors
Gets the list of element descriptors persisted against this descriptor.
Declaration
[Browsable(false)]
[DataMember(Name = "Elements")]
public Dictionary<string, ElementDescriptor> ElementDescriptors { get; set; }
Property Value
ExtensionData
Declaration
[Browsable(false)]
public virtual ExtensionDataObject ExtensionData { get; set; }
Property Value
Implements
FriendlyDescription
Get a friendly description of this descriptor to show in the scenario explorer.
Declaration
[Browsable(false)]
public virtual string FriendlyDescription { get; }
Property Value
HasQuickTasks
Gets whether this descriptors supports a quick task or not.
Declaration
[Browsable(false)]
public bool HasQuickTasks { get; }
Property Value
IsSearchByImageApllicable
True if the image search option for the element is applicable for the descriptor.
Declaration
[Browsable(false)]
public virtual bool IsSearchByImageApllicable { get; set; }
Property Value
LogMessageOnFailure
Get or set the message on log on failure
Declaration
[DataMember(Name = "LogMessageOnFailure")]
public string LogMessageOnFailure { get; set; }
Property Value
Pause
Declaration
[DataMember(Name = "Pause")]
public StepPauseType Pause { get; set; }
Property Value
PrimaryProperties
Declaration
[Browsable(false)]
public IEnumerable<PropertyInfo> PrimaryProperties { get; }
Property Value
PrimaryTarget
Declaration
public virtual ElementDescriptor PrimaryTarget { get; set; }
Property Value
PrimaryTargetKey
Gets the primary target key
Declaration
[Browsable(false)]
public virtual string PrimaryTargetKey { get; }
Property Value
QuickTasks
Gets the quick task if one exists else null
Declaration
[Browsable(false)]
public IQuickTasks QuickTasks { get; }
Property Value
RequiredAssemblyReferences
Any addition assembly references to be added to the project on code gen.
Declaration
[Browsable(false)]
public virtual string[] RequiredAssemblyReferences { get; }
Property Value
string[]
RunsAgainst
Declaration
[DataMember(Name = "RunsAgainst", EmitDefaultValue = false)]
public BrowserConstraints RunsAgainst { get; set; }
Property Value
RunsAgainstVersion
Declaration
[DataMember(Name = "RunsAgainstVersion", EmitDefaultValue = false)]
public string RunsAgainstVersion { get; set; }
Property Value
RunsAgainstVersionCompare
Declaration
[DataMember(Name = "RunsAgainstVersionCompare", EmitDefaultValue = false)]
public NumberCompareType RunsAgainstVersionCompare { get; set; }
Property Value
SearchByImageFirst
Declaration
[DataMember(Name = "SearchByImageFirst")]
[PrimaryProperty]
public virtual SearchElementOrderType SearchByImageFirst { get; set; }
Property Value
SecondaryTarget
Declaration
public virtual ElementDescriptor SecondaryTarget { get; set; }
Property Value
SecondaryTargetKey
Gets the secondary target key
Declaration
[Browsable(false)]
public virtual string SecondaryTargetKey { get; }
Property Value
StepType
Gets the step type.
Declaration
[DataMember(Name = "StepType")]
public AutomationDescriptorType StepType { get; set; }
Property Value
SupportsConvertToCode
Whether the descriptor supports convert to code or not.
Declaration
[Browsable(false)]
public virtual bool SupportsConvertToCode { get; }
Property Value
TargetSearchAlgorithm
Declaration
[Browsable(false)]
public TargetSearchAlgorithm TargetSearchAlgorithm { get; }
Property Value
Targets
Gets the list of target elements to use for automation within this descriptor.
Declaration
[Browsable(false)]
public Dictionary<string, ITargetElement> Targets { get; set; }
Property Value
TargetsCustomControlTypes
Gets the targets custom control types for code-gen
Declaration
[Browsable(false)]
public Dictionary<string, Type> TargetsCustomControlTypes { get; }
Property Value
TechnologyType
Gets the technology that this step runs against
Declaration
[Browsable(false)]
public virtual TechnologyType TechnologyType { get; set; }
Property Value
TestMethod
Gets the codeDom test method for codegen of this descriptor.
Declaration
[Browsable(false)]
public CodeMemberMethod TestMethod { get; set; }
Property Value
UseStepWaitOnElementsTimout
Declaration
[DataMember(Name = "UseStepWaitOnElementsTimout", IsRequired = false)]
public virtual bool UseStepWaitOnElementsTimout { get; set; }
Property Value
WaitOnElements
Declaration
[DataMember(Name = "WaitOnElements")]
public virtual bool WaitOnElements { get; set; }
Property Value
WaitOnElementsTimeout
Declaration
[DataMember(Name = "WaitOnElementsTimeout")]
public virtual int WaitOnElementsTimeout { get; set; }
Property Value
Methods
AreSameIncludingElements(AutomationDescriptor, AutomationDescriptor)
Returns true/false whether two descriptors are the same and have identical targets This function assumes that both descriptors have the same set of key names
Declaration
public static bool AreSameIncludingElements(AutomationDescriptor desc1, AutomationDescriptor desc2)
Parameters
desc1
The first decriptor
desc2
The second descriptor
Returns
True/False on whether the descriptors match.
BindData(string)
If the descriptor supports data driven tests, then it can use this expand method to expand bindable properties or data before execution.
ChangeTarget(ElementDescriptor, string)
Change a descriptors element
Declaration
protected void ChangeTarget(ElementDescriptor descriptor, string targetName)
Parameters
descriptor
targetName
Clone()
Clone this descriptor
Declaration
public AutomationDescriptor Clone()
Returns
The cloned descriptor
ConsolidateText(string, string)
Consolidate the text
ConsolidateText(string, string, TextTypingInfo)
Declaration
public static string ConsolidateText(string original, string added, TextTypingInfo info)
Parameters
original
added
info
Returns
CreateElementFindExpression(string)
Creates a CodeDOM expression for the element's terminal FindExpression
Declaration
protected virtual CodeExpression CreateElementFindExpression(string elementKey)
Parameters
elementKey
Key into this descriptors collection of element descriptors for the desired element
Returns
A CodeDOM expression that constructs a new FindExpression specifying the desired element
CreateElementReference(string)
Declaration
protected virtual CodeExpression CreateElementReference(string elementKey)
Parameters
elementKey
Returns
CreateElementReference(string, bool, int)
Declaration
protected virtual CodeExpression CreateElementReference(string elementKey, bool waitForExistsState, int waitForExistsTimeout)
Parameters
elementKey
waitForExistsState
waitForExistsTimeout
Returns
GenerateLambdaExpression(CodeVariableReferenceExpression, CodeExpression, bool)
Declaration
protected CodeSnippetExpression GenerateLambdaExpression(CodeVariableReferenceExpression lambdaVarRef, CodeExpression lambdaValueExpr, bool isPositiveExpression = true)
Parameters
lambdaVarRef
CodeVariableReferenceExpression
lambdaValueExpr
isPositiveExpression
Returns
GenerateLambdaExpression(CodeVariableReferenceExpression[], CodeExpression, bool)
Declaration
protected CodeSnippetExpression GenerateLambdaExpression(CodeVariableReferenceExpression[] lambdaVarRefs, CodeExpression lambdaValueExpr, bool isPositiveExpression = true)
Parameters
lambdaVarRefs
CodeVariableReferenceExpression[]
lambdaValueExpr
isPositiveExpression
Returns
GenerateLambdaVariableRef()
Declaration
protected CodeVariableReferenceExpression GenerateLambdaVariableRef()
Returns
GenerateLambdaVariableRef(int)
Declaration
protected CodeVariableReferenceExpression GenerateLambdaVariableRef(int index)
Parameters
index
Returns
GenerateTernaryExpression(CodeExpression, CodeExpression, CodeExpression)
Declaration
protected CodeSnippetExpression GenerateTernaryExpression(CodeExpression condition, CodeExpression trueExpr, CodeExpression falseExpr)
Parameters
condition
trueExpr
falseExpr
Returns
GetAttributes()
Declaration
public AttributeCollection GetAttributes()
Returns
Implements
GetDefaultEvent()
Declaration
public EventDescriptor GetDefaultEvent()
Returns
Implements
GetDefaultProperty()
Declaration
public PropertyDescriptor GetDefaultProperty()
Returns
Implements
GetEvents()
Declaration
public EventDescriptorCollection GetEvents()
Returns
Implements
GetEvents(Attribute[])
Declaration
public EventDescriptorCollection GetEvents(Attribute[] attributes)
Parameters
attributes
Returns
Implements
GetLambdaExpression(CodeGenerationLanguage, CodeExpression)
Declaration
protected virtual string GetLambdaExpression(CodeGenerationLanguage language, CodeExpression expression)
Parameters
language
expression
Returns
GetLambdaExpression(CodeGenerationLanguage, CodeExpression, bool)
Declaration
protected virtual string GetLambdaExpression(CodeGenerationLanguage language, CodeExpression expression, bool isPositiveExpression)
Parameters
language
expression
isPositiveExpression
Returns
GetLambdaVariableReference()
Declaration
protected virtual CodeVariableReferenceExpression GetLambdaVariableReference()
Returns
GetNoParamLamdaExpression(CodeGenerationLanguage, CodeExpression)
Declaration
protected virtual string GetNoParamLamdaExpression(CodeGenerationLanguage language, CodeExpression expression)
Parameters
language
expression
Returns
GetNumberedVariableName(string)
Gets a variable name of the form baseName_i that isn't used yet in this descriptor's TestMethod statements collection.
GetParentsReference(ElementDescriptor)
Declaration
protected CodeExpression GetParentsReference(ElementDescriptor descriptor)
Parameters
descriptor
Returns
GetProjectLanguage()
Get the code generation language.
Declaration
public CodeGenerationLanguage GetProjectLanguage()
Returns
The language enum
GetProperties()
Declaration
public PropertyDescriptorCollection GetProperties()
Returns
Implements
GetProperties(Attribute[])
Declaration
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
Parameters
attributes
Returns
Implements
GetPropertyOwner(PropertyDescriptor)
Declaration
public object GetPropertyOwner(PropertyDescriptor pd)
Parameters
pd
Returns
Implements
InvokeMethod(CodeExpression, bool, string, CodeGenerationLanguage, params object[])
Invoke a method on a control
Declaration
protected virtual CodeExpression InvokeMethod(CodeExpression controlReference, bool invoke, string methodName, CodeGenerationLanguage language, params object[] parameters)
Parameters
controlReference
invoke
Flag whether to add statement to code generation collection or just return the generated code expression.
methodName
language
The language in which to generate the method call
parameters
object[]
Returns
InvokeMethod(CodeExpression, bool, string, params object[])
Invoke a method on a control
Declaration
protected virtual CodeExpression InvokeMethod(CodeExpression controlReference, bool invoke, string methodName, params object[] parameters)
Parameters
controlReference
invoke
Flag whether to add statement to code generation collection or just return the generated code expression.
methodName
parameters
object[]
Returns
InvokeMethod(string, Type, bool, string, CodeGenerationLanguage, params object[])
Generate code that invokes a method on a control
Declaration
protected virtual CodeExpression InvokeMethod(string elementKey, Type controlType, bool invokeMethod, string methodName, CodeGenerationLanguage language, params object[] parameters)
Parameters
elementKey
controlType
invokeMethod
methodName
language
The language in which to generate the method call
parameters
object[]
Returns
InvokeMethod(string, Type, bool, string, params object[])
Generate code that invokes a method on a control. Generates code in the language of the current project.
Declaration
protected virtual CodeExpression InvokeMethod(string elementKey, Type controlType, bool invokeMethod, string methodName, params object[] parameters)
Parameters
elementKey
controlType
invokeMethod
methodName
parameters
object[]
Returns
InvokeMethod(string, bool, string, CodeGenerationLanguage, params object[])
Generate code that invokes a method on an object, and optionally add the code to the steps for the current test
Declaration
protected virtual CodeExpression InvokeMethod(string objectName, bool invoke, string methodName, CodeGenerationLanguage language, params object[] parameters)
Parameters
objectName
The name of the object
invoke
Whether to add the code to the current test's steps
methodName
The name of the method
language
The language in which to generate the method call
parameters
object[]
Parameters for the method call
Returns
A CodeExpression representing the method call
InvokeMethod(string, bool, string, params object[])
Generate code that invokes a method on an object, and optionally add the code to the steps for the current test. Generates code in the language of the current project.
Declaration
protected virtual CodeExpression InvokeMethod(string objectName, bool invoke, string methodName, params object[] parameters)
Parameters
objectName
The name of the object
invoke
Whether to add the code to the current test's steps
methodName
The name of the method
parameters
object[]
Parameters for the method call
Returns
A CodeExpression representing the method call
InvokeMethod(string, string, CodeGenerationLanguage, params object[])
Generate code that invokes a method on an object, and add the code to the steps for the current test
Declaration
protected virtual CodeExpression InvokeMethod(string objectName, string methodName, CodeGenerationLanguage language, params object[] parameters)
Parameters
objectName
The name of the object
methodName
The name of the method
language
The language in which to generate the method call
parameters
object[]
Parameters for the method call
Returns
A CodeExpression representing the method call
InvokeMethod(string, string, params object[])
Generate code that invokes a method on an object, and add the code to the steps for the current test. Generates code in the language of the current project.
Declaration
protected virtual CodeExpression InvokeMethod(string objectName, string methodName, params object[] parameters)
Parameters
objectName
The name of the object
methodName
The name of the method
parameters
object[]
Parameters for the method call
Returns
A CodeExpression representing the method call
InvokeWaitForExistsMethod(CodeExpression)
Invoke a method on a control
Declaration
protected virtual CodeExpression InvokeWaitForExistsMethod(CodeExpression controlReference)
Parameters
controlReference
Returns
InvokeWaitMethod(string, Type, int, int, CodeExpression)
Declaration
protected virtual CodeExpression InvokeWaitMethod(string elementKey, Type controlType, int timeOut, int checkInterval, CodeExpression lambdaStatement)
Parameters
elementKey
controlType
timeOut
checkInterval
lambdaStatement
Returns
InvokeWaitMethod(string, Type, int, int, CodeExpression, CodeGenerationLanguage)
Declaration
protected virtual CodeExpression InvokeWaitMethod(string elementKey, Type controlType, int timeOut, int checkInterval, CodeExpression lambdaStatement, CodeGenerationLanguage language)
Parameters
elementKey
controlType
timeOut
checkInterval
lambdaStatement
language
Returns
InvokeWaitMethod(string, Type, int, int, string, CodeGenerationLanguage, params object[])
Declaration
protected virtual CodeExpression InvokeWaitMethod(string elementKey, Type controlType, int timeOut, int checkInterval, string methodName, CodeGenerationLanguage language, params object[] parameters)
Parameters
elementKey
controlType
timeOut
checkInterval
methodName
language
parameters
object[]
Returns
InvokeWaitMethod(string, Type, int, int, string, params object[])
Declaration
protected virtual CodeExpression InvokeWaitMethod(string elementKey, Type controlType, int timeOut, int checkInterval, string methodName, params object[] parameters)
Parameters
elementKey
controlType
timeOut
checkInterval
methodName
parameters
object[]
Returns
IsDataBound(string)
Gets whether a property of this descriptor is data bound or not.
NotifyElementNameChange(ElementDescriptor)
Useful for custom translator descriptors to update their their friendly descriptions accordingly.
Declaration
public virtual void NotifyElementNameChange(ElementDescriptor elementDescriptor)
Parameters
elementDescriptor
The element descriptor associated with that change.
OnBeforeConfirmRecording(object)
This method is called before an automation descriptor is recorded into the Test Explorer and allows the descriptor to perform any processing it may need to before it is recorded.
Declaration
public virtual void OnBeforeConfirmRecording(object data)
Parameters
data
Unused. Will be null.
OnBeforeElementDescriptorAdded(string, ITargetElement, FindExpressionElement)
This method is called before an ElementDescriptor is added to the ElementDescriptors collection and allows a descriptor to edit the FindExpression generated for that element.
Declaration
public virtual void OnBeforeElementDescriptorAdded(string key, ITargetElement targetElement, FindExpressionElement generatedElement)
Parameters
key
The key used to add to the Targets collection.
targetElement
The target element the expression was generated for.
generatedElement
The generated FindExpression
OnPropertyChanged(string)
Invoke the property changed event.
Declaration
public virtual void OnPropertyChanged(string propertyName)
Parameters
propertyName
The property name
ParseParameters(object[], out bool, CodeGenerationLanguage)
Create parameter array from all passed in parameters
Declaration
protected CodeExpression[] ParseParameters(object[] parameters, out bool isDataBound, CodeGenerationLanguage language)
Parameters
parameters
object[]
isDataBound
language
Returns
SetProperty(CodeExpression, object)
Sets a property for a given control
Declaration
protected virtual void SetProperty(CodeExpression controlReference, object propertyName)
Parameters
controlReference
propertyName
SetProperty(CodeExpression, object, CodeGenerationLanguage)
Sets a property for a given control
Declaration
protected virtual void SetProperty(CodeExpression controlReference, object propertyName, CodeGenerationLanguage language)
Parameters
controlReference
propertyName
language
SetProperty(string, Type, object)
Generates code for a set property on a control
SetProperty(string, Type, object, CodeGenerationLanguage)
Generates code for a set property on a control
Declaration
protected virtual void SetProperty(string elementKey, Type controlType, object propertyName, CodeGenerationLanguage language)
Parameters
elementKey
controlType
propertyName
language
ToCode()
This method is called when the user requests code generation. The framework initializes the TestMethod property of this object with a new instance that this method simply needs to add its custom codegen to it.
Declaration
public virtual void ToCode()
ToString()
String representation of an AutomationDescriptors
UsesTarget(string)
Whether or not this descriptor will use a target when it executes.
Declaration
public virtual bool UsesTarget(string target)
Parameters
target
Returns
Remarks
Most descriptors use all of their targets, but some descriptors only use certain targets in specific modes. This method lets us check whether a descriptor uses a target in the mode the descriptor is currently in.
Events
PropertyChanged
Occurs when a property of the descriptor changes
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Value
Implements