Class Control
- Namespace
- Ranorex
- Assembly
- Ranorex.Plugin.WinForms.dll
Capability of a .NET Windows Forms control.
public class Control : Adapter, IAdapter
- Inheritance
-
Control
- Implements
- Inherited Members
Constructors
Control()
Creates a new Control adapter instance. This constructor is used internally by the Ranorex Core Framework for performance issues!
protected Control()
Control(Element)
Creates a new Control adapter instance.
public Control(Element element)
Parameters
elementElementThe element to create the adapter for.
Exceptions
- NullReferenceException
If
elementisnull.- CapabilityNotSupportedException
If the element does not support the capabilities required by this adapter.
Properties
this[string]
Gets or sets the (serializable) value of the specified control property.
public object this[string name] { get; set; }
Parameters
namestringThe name of the property.
Property Value
- object
The value of the property.
Remarks
The getter of this property calls the GetPropertyValue(string) method, the setter calls the SetPropertyValue(string, object) method.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
Name
The name of the Windows Forms control.
[OriginalDisplayName("ControlName")]
public virtual string Name { get; }
Property Value
RequiredCapabilities
Capabilities required by the adapter implementation.
protected override string[] RequiredCapabilities { get; }
Property Value
- string[]
Text
The text of the Windows Forms control.
[OriginalDisplayName("ControlText")]
public virtual string Text { get; set; }
Property Value
Exceptions
- SetAttributeFailedException
Thrown if setting the attribute value failed.
Type
The full type name of the Windows Forms control.
[OriginalDisplayName("ControlType")]
public virtual string Type { get; }
Property Value
TypeName
The (short) type name of the Windows Forms control.
[OriginalDisplayName("ControlTypeName")]
public virtual string TypeName { get; }
Property Value
Methods
FromElement(Element)
Converts an Element to an instance of this class.
public static Control FromElement(Element element)
Parameters
elementElementThe element to convert.
Returns
- Control
The Control.
Exceptions
- ArgumentNullException
If
elementisnull.- CapabilityNotSupportedException
If the element does not support the capabilities required by this adapter.
FromPath(string)
Converts a string to an instance of this class by searching the root.
public static Control FromPath(string path)
Parameters
pathstringThe search path.
Returns
- Control
The Control.
Remarks
The DefaultSearchTimeout is used to search for the specified path.
Exceptions
- ArgumentNullException
If
pathisnull.- RxPathException
If the specified
pathis not valid.- ElementNotFoundException
If no element is found.
- CapabilityNotSupportedException
If the element does not support the capabilities required by this adapter.
GetPropertyValue(BindingFlags, string)
Gets the (serializable) value of the specified control property.
public virtual object GetPropertyValue(BindingFlags flags, string name)
Parameters
flagsBindingFlagsA combination of flags that further specify which property to get.
namestringThe name of the property.
Returns
- object
The value of the property.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
GetPropertyValue(string)
Gets the (serializable) value of the specified control property.
public virtual object GetPropertyValue(string name)
Parameters
namestringThe name of the property.
Returns
- object
The value of the property.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
GetPropertyValue<T>(BindingFlags, string)
Gets the (serializable) value of the specified control property.
public T GetPropertyValue<T>(BindingFlags flags, string name)
Parameters
flagsBindingFlagsA combination of flags that further specify which property to get.
namestringThe name of the property.
Returns
- T
The value of the named property or the default value of the specified type if the returned value is
nulland the specified type is a value type.
Type Parameters
TThe type of the property to get the value from.
Exceptions
- InvalidCastException
If the returned value cannot be casted to the specified type.
- ActionFailedException
Thrown if invoking the action failed.
GetPropertyValue<T>(string)
Gets the (serializable) value of the specified control property.
public T GetPropertyValue<T>(string name)
Parameters
namestringThe name of the property.
Returns
- T
The value of the named property or the default value of the specified type if the returned value is
nulland the specified type is a value type.
Type Parameters
TThe type of the property to get the value from.
Exceptions
- InvalidCastException
If the returned value cannot be casted to the specified type.
- ActionFailedException
Thrown if invoking the action failed.
InvokeMethod(BindingFlags, string, object[])
Invokes the specified method on the control. All parameters and the return value need to be serializable.
public object InvokeMethod(BindingFlags flags, string name, object[] args)
Parameters
flagsBindingFlagsA combination of flags that further specify which method to invoke.
namestringThe name of the method to invoke.
argsobject[]The (serializable) values passed as parameters to the method.
Returns
- object
The (serializable) return value of the invoked method.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
InvokeMethod(BindingFlags, string, object[], Duration)
Invokes the specified method on the control. All parameters and the return value need to be serializable.
public virtual object InvokeMethod(BindingFlags flags, string name, object[] args, Duration timeout)
Parameters
flagsBindingFlagsA combination of flags that further specify which method to invoke.
namestringThe name of the method to invoke.
argsobject[]The (serializable) values passed as parameters to the method.
timeoutDurationThe timeout for this action. The action will return after the timeout even if the method has not yet finished executing.
Returns
- object
The (serializable) return value of the invoked method.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
InvokeMethod(string)
Invokes the specified method on the control.
public object InvokeMethod(string name)
Parameters
namestringThe name of the method to invoke.
Returns
- object
The (serializable) return value of the invoked method.
Remarks
Use this method to invoke public instance methods without arguments on a control.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
InvokeMethod(string, object[])
Invokes the specified method on the control. All parameters need to be serializable.
public object InvokeMethod(string name, object[] args)
Parameters
namestringThe name of the method to invoke.
argsobject[]The (serializable) values passed as parameters to the method.
Returns
- object
The (serializable) return value of the invoked method.
Remarks
Use this method to invoke public instance methods on a control.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
InvokeRemotely(RemotelyInvokedDelegate)
Invokes the delegate remotely at the control. All parameters and the return value need to be serializable.
public object InvokeRemotely(RemotelyInvokedDelegate deleg)
Parameters
delegRemotelyInvokedDelegateThe delegate to invoke at the remote control.
Returns
- object
The (serializable) return value of the remotely invoked delegate.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
InvokeRemotely(RemotelyInvokedDelegate, object)
Invokes the delegate remotely at the control. All parameters and the return value need to be serializable.
public object InvokeRemotely(RemotelyInvokedDelegate deleg, object inputData)
Parameters
delegRemotelyInvokedDelegateThe delegate to invoke at the remote control.
inputDataobjectThe (serializable) input data passed to the delegate at the remote control.
Returns
- object
The (serializable) return value of the remotely invoked delegate.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
InvokeRemotely(RemotelyInvokedDelegate, object, Duration)
Invokes the delegate remotely at the control. All parameters and the return value need to be serializable.
public virtual object InvokeRemotely(RemotelyInvokedDelegate deleg, object inputData, Duration timeout)
Parameters
delegRemotelyInvokedDelegateThe delegate to invoke at the remote control.
inputDataobjectThe (serializable) input data passed to the delegate at the remote control.
timeoutDurationThe timeout for this action. The action will return after the timeout even if the delegate has not yet finished executing.
Returns
- object
The (serializable) return value of the remotely invoked delegate.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
SetPropertyValue(BindingFlags, string, object)
Sets the (serializable) value of the specified control property.
public virtual void SetPropertyValue(BindingFlags flags, string name, object value)
Parameters
flagsBindingFlagsA combination of flags that further specify which property to set.
namestringThe name of the property.
valueobjectThe value (must be serializable) to set the property to.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
SetPropertyValue(string, object)
Sets the (serializable) value of the specified control property.
public virtual void SetPropertyValue(string name, object value)
Parameters
namestringThe name of the property.
valueobjectThe value (must be serializable) to set the property to.
Exceptions
- ActionFailedException
Thrown if invoking the action failed.
Operators
implicit operator Control(Element)
Implicitly converts an Element to an instance of this class.
public static implicit operator Control(Element element)
Parameters
elementElementThe element to convert.
Returns
- Control
The Control.
Exceptions
- ArgumentNullException
If
elementisnull.- CapabilityNotSupportedException
If the element does not support the capabilities required by this adapter.
implicit operator Control(string)
Implicitly converts a string to an instance of this class by searching the root.
public static implicit operator Control(string path)
Parameters
pathstringThe search path.
Returns
- Control
The Control.
Remarks
The DefaultSearchTimeout is used to search for the specified path.
Exceptions
- ArgumentNullException
If
pathisnull.- RxPathException
If the specified
pathis not valid.- ElementNotFoundException
If no element is found.
- CapabilityNotSupportedException
If the element does not support the capabilities required by this adapter.