Table of Contents

Class FlavorElement

Namespace
Ranorex.Core
Assembly
Ranorex.Core.dll

A container for flavor-specific element data which handles the default element properties.

public abstract class FlavorElement : MarshalByRefObject
Inheritance
FlavorElement
Derived
Inherited Members

Constructors

FlavorElement(string)

Creates a new flavor element.

protected FlavorElement(string flavorName)

Parameters

flavorName string

The flavor name for this flavor element.

Properties

DontCache

Indicates that the element should not be cached. Defaults to false.

protected virtual bool DontCache { get; }

Property Value

bool

ElementRectangle

The client or screen rectangle of the flavor element depending on the value returned by IsClientRectangle.

public abstract Rectangle ElementRectangle { get; }

Property Value

Rectangle

Remarks

To be implemented by the deriving class.

Enabled

True if the element is enabled. If the element cannot be enabled or disabled, return true.

public abstract bool Enabled { get; }

Property Value

bool

Remarks

To be implemented by the deriving class.

EnsureVisibleBehavior

Describes how EnsureVisible() calls are forwarded to a FlavorElement.

public virtual EnsureVisibleBehaviorType EnsureVisibleBehavior { get; }

Property Value

EnsureVisibleBehaviorType

EvaluateExpensiveAttributes

Gets a value indicating whether expensive attributes should be evaluated.

protected bool EvaluateExpensiveAttributes { get; }

Property Value

bool

true if expensive attributes should be evaluated; otherwise, false.

Remarks

This property checks whether Ranorex.Libs.RanorexEnvironment.IsRanorexApplication is enabled and if expensive attributes are disabled when running in tools.

Flavor

The flavor of the flavor element.

public Flavor Flavor { get; }

Property Value

Flavor

FlavorName

The flavor name of the flavor element.

public string FlavorName { get; }

Property Value

string

ForceGeometricSearchAll

Determines if the ElementRectangle is expected to be outside the bounds of its parent rectangle, and might be invisible. Forces FindChildFromPointByRectangle() to switch to 'search all' behavior.

public virtual bool ForceGeometricSearchAll { get; }

Property Value

bool

Remarks

To be overridden by the deriving class. Returns false by default.

HasFocus

True if the element has the focus.

public abstract bool HasFocus { get; }

Property Value

bool

Remarks

To be implemented by the deriving class.

IsClientRectangle

Determines if the ElementRectangle property returns client or screen coordinates.

public abstract bool IsClientRectangle { get; }

Property Value

bool

Remarks

To be implemented by the deriving class.

IsUidDomainRoot

Gets a value indicating whether this flavor element can act as a unique id domain root.

public virtual bool IsUidDomainRoot { get; }

Property Value

bool

true if this instance is uid domain root; otherwise, false.

MinPathAttributes

Indicates that the minimum number of attributes to use when creating an RxPath location step for this element. Defaults to 0.

protected virtual int MinPathAttributes { get; }

Property Value

int

SupportsNativePathSearch

Indicates whether this flavor element supports searching for native RxPaths

public virtual bool SupportsNativePathSearch { get; }

Property Value

bool

Valid

True if the flavor element is still valid.

public abstract bool Valid { get; }

Property Value

bool

Remarks

To be implemented by the deriving class.

Visible

True if the element is visible.

public abstract bool Visible { get; }

Property Value

bool

Remarks

To be implemented by the deriving class.

Methods

AssertArgumentType(Type, object)

Validates the type of an argument.

protected static void AssertArgumentType(Type type, object arg)

Parameters

type Type

The asserted type.

arg object

The object to be asserted.

Remarks

null is not considered a valid argument.

Exceptions

ArgumentException

Thrown if the types do not match.

AssertArgumentType(Type, object, bool)

Validates the type of an argument.

protected static void AssertArgumentType(Type type, object arg, bool allowNull)

Parameters

type Type

The asserted type.

arg object

The object to be asserted.

allowNull bool

A value specifying whether null is a valid argument.

Exceptions

ArgumentException

Thrown if the types do not match.

AssertArgumentTypes(Type[], object[])

Validates a list of argument objects against a list of types.

protected static void AssertArgumentTypes(Type[] types, object[] args)

Parameters

types Type[]

The list of types.

args object[]

The list of argument instances.

Remarks

null is not considered a valid argument.

Exceptions

ArgumentException

Thrown if the argument count or argument types do not match.

AssertArgumentTypes(Type[], object[], bool[])

Validates a list of argument objects against a list of types.

protected static void AssertArgumentTypes(Type[] types, object[] args, bool[] allowNull)

Parameters

types Type[]

The list of types.

args object[]

The list of argument instances.

allowNull bool[]

A list of values specifying whether null is a valid argument.

Exceptions

ArgumentException

Thrown if the argument count or argument types do not match.

CanReplace(FlavorElement)

Returns a value specifying if this flavor element can replace elem.

public virtual bool CanReplace(FlavorElement elem)

Parameters

elem FlavorElement

The element to replace.

Returns

bool

True if this flavor element can replace elem, otherwise false.

Remarks

The base method returns true if this flavor element IsEqual(FlavorElement) to elem.

EnsureVisible()

Ensures that the flavor element is visible.

public abstract bool EnsureVisible()

Returns

bool

True if the operation was successful.

Focus()

Focuses the flavor element, if possible.

public abstract void Focus()

GetAttributeValue(Element, string)

Needs to be implemented for attribute value read access.

public abstract object GetAttributeValue(Element element, string name)

Parameters

element Element

The element instance used.

name string

The name of the attribute (lowercased).

Returns

object

The attribute value.

GetChildLineageFromPoint(Point, out FindRefineMode)

Returns a list of flavor elements that is the lineage to the flavor element at the specified screen location.

public abstract LinkedList<FlavorElement> GetChildLineageFromPoint(Point screenLocation, out FindRefineMode refineMode)

Parameters

screenLocation Point

The screen location to search at.

refineMode FindRefineMode

Can be set to indicate that further searching is required.

Returns

LinkedList<FlavorElement>

The lineage to the flavor element at the specified point as a list.

Remarks

The first element in the returned list is the direct child of this flavor element, the k-th element is the parent of the (k+1)-th element, and the last element is the actual flavor element at the specified screen location. Consequently, an empty list is to be returned if this element is the best fitting element at the requested point.

Returns null if the specified screenLocation is not within this or one of its descendant elements.

GetChildLineageFromUid(string, out UidFindResult)

Gets the child lineage from the current element to the element with the given unique id.

public virtual LinkedList<FlavorElement> GetChildLineageFromUid(string uidValue, out UidFindResult result)

Parameters

uidValue string

The uid value to search for.

result UidFindResult

The result status. This defaults to FindStatus.NotSupported if the flavor does not support unique id search.

Returns

LinkedList<FlavorElement>

A lineage of elements or null if nothing was found or the method is not supported.

GetChildLineagesFromPath(RxPath, int, bool, out int)

Gets the child lineages from the current element to the elements with the given RxPath.

public virtual IList<LinkedList<FlavorElement>> GetChildLineagesFromPath(RxPath path, int startIndex, bool findSingle, out int consumedSteps)

Parameters

path RxPath

The relative RxPath to search for.

startIndex int

The index to start searching from in the supplied RxPath.

findSingle bool

Indicates whether the search should complete after matching one element.

consumedSteps int

The number of steps consumed in the RxPath by the search operation.

Returns

IList<LinkedList<FlavorElement>>

Lineages of elements or an empty list if nothing was found, or null if the operation failed for some reason.

Remarks

Implementations are allowed to not process the whole path by specifying a consumedSteps length shorter than the complete path suffix length (from startIndex).

GetDynamicDescriptors(out IList<AttributeDescriptor>, out IList<ActionDescriptor>)

Gets the descriptors for the dynamic attributes and actions that the element supports.

public virtual void GetDynamicDescriptors(out IList<AttributeDescriptor> attributes, out IList<ActionDescriptor> actions)

Parameters

attributes IList<AttributeDescriptor>

The dynamic attributes that the element supports.

actions IList<ActionDescriptor>

The dynamic actions that the element supports.

Remarks

The default implementation returns empty lists for attributes and actions. Any overriding method should fill the returned lists.

GetElementCapabilities(Element, out Role, out string[], out string)

Supplies the role, a list of capabilities and a preferred capability names to the caller. This method called when building a new element from the flavor element.

public abstract void GetElementCapabilities(Element parent, out Role role, out string[] capabilities, out string preferredCap)

Parameters

parent Element

The parent element of the element to be constructed. (for reference only)

role Role

The role the element should have.

capabilities string[]

The list of capabilities the element should have.

preferredCap string

The preferred capability the element should have.

GetInitialValues()

Gets the initial cacheable values which are then stored in the active cache session, if any.

public virtual IDictionary<string, object> GetInitialValues()

Returns

IDictionary<string, object>

A list of key/value pairs with initial values.

GetRuntimeTokenValues()

Gets the runtime token values. This must be implemented by the flavors.

protected abstract object[] GetRuntimeTokenValues()

Returns

object[]

A collection of objects representing a runtime token.

HitTest(Point)

Performs an optional hit test on a point within the element's rectangle. The default implementation returns 'true'.

protected virtual bool HitTest(Point localPoint)

Parameters

localPoint Point

The point in local coordinates.

Returns

bool

Returns true if the point is within the element, otherwise false.

Remarks

This should return 'false' if the point is transparent regarding to mouse clicks.

InvokeAction(Element, string, object[])

Needs to be implemented for element action invocation.

public abstract object InvokeAction(Element element, string name, object[] args)

Parameters

element Element

The element instance used.

name string

The name of the action (lowercased).

args object[]

A list of invocation parameters.

Returns

object

The invocation result. Can be null if the return type is void.

IsEqual(FlavorElement)

Compares to flavor elements. This should be implemented using the best comparison method available.

public virtual bool IsEqual(FlavorElement flavorElem)

Parameters

flavorElem FlavorElement

The flavor element to compare to.

Returns

bool

True if the flavor elements are equal.

Remarks

The base method compares the token values returned by GetRuntimeTokenValues().

SetAttributeValue(Element, string, object)

Needs to be implemented for attribute value write access.

public abstract void SetAttributeValue(Element element, string name, object value)

Parameters

element Element

The element instance used.

name string

The name of the attribute (lowercased).

value object

The attribute value to be set.