ClassElement
Represents an element in the Document Object Model (DOM) tree.
Definition
Namespace:ArtOfTest.WebAii.ObjectModel
Assembly:ArtOfTest.WebAii.dll
Syntax:
public class Element : ITargetElement
Inheritance: objectElement
Implements:
Constructors
Element(HtmlFindExpression, Find, Browser)
Initialize an element proxy. The only property off this element that you can use is Wait.Exist() or Wait.ExistsNot()
Declaration
public Element(HtmlFindExpression findExpr, Find findObj, Browser ownerBrowser)
Parameters
findExpr
A FindExpression identifying this element
findObj
The Find object to use
ownerBrowser
Owner browser
Properties
AbsoluteSiblingTagIndex
Gets the absolute sibling tag index of this element within the parent node. Basically the order of this node among its siblings. Zero-based.
AbsoluteTagIndex
Gets the absolute that index of this element. This index is unique within a document.
Attributes
Gets the list of attributes defined for this element.
Declaration
public ReadOnlyCollection<iAttribute> Attributes { get; }
Property Value
ChildNodes
Gets the list of all parsed element of this tag including text literals, comments, malformed tags...etc.
Declaration
public ReadOnlyCollection<Element> ChildNodes { get; }
Property Value
Children
Gets the list of child elements that are well formed markup non-text elements.
Declaration
public ReadOnlyCollection<Element> Children { get; }
Property Value
Content
Gets the raw content of the tag that represents this element.
The following tag <foo id="bar" height="px">some text</foo> , has a Content property that is:
'<foo id="bar" height="px">'
Note: this does not include the innerText or the closing tag.
CssClassAttributeValue
Gets the value of the attribute ('class') if present on this tag.
Data
Gets/Sets any custom data associated with this element.
Depth
Gets the hierarchical depth of this element
ElementType
Gets the element type (div, table ..etc).
FindExpressionUsed
Gets the FindExpression used to find this element when using the Find object. This property is not set when calling the Find.Allxxx methods.
Declaration
[Browsable(false)]
public HtmlFindExpression FindExpressionUsed { get; }
Property Value
FindObjectUsed
Gets a reference to the Find object used to find this element
Declaration
[Browsable(false)]
public Find FindObjectUsed { get; }
Property Value
FrameElement
Gets / Sets the root frame element that this element is contained in.
HasIdOrName
Gets whether this element has an id or a name set on it.
Declaration
public bool HasIdOrName { get; }
Property Value
True/False whether or not this element has an ID or a Name attribute applied to it.
Host
Get the IAutomationHost associated with this element.
Declaration
public IAutomationHost Host { get; }
Property Value
Implements
IdAttributeValue
Gets the value of the attribute ('id') if present on this tag.
InnerMarkup
Gets the InnerMarkup of this element.
Example:
<foo id="1">hello<bar></bar></foo>
If foo is this element then InnerMarkup=<bar></bar>
InnerText
Gets this element's inner text content including all of its nested children.
Example:
<foo id="1">one<bar>two</bar></foo>
If foo is this element then InnerText=onetwo
InputElementType
Gets the Input type (i.e. checkbox, radio...etc) if the ElementType=Input. Otherwise, will return NotSet.
Declaration
public InputElementType InputElementType { get; }
Property Value
IsBeginTag
Gets whether it is a begin tag <foo bar='me'> .
IsEndTag
Gets whether this element is an end tag </foo>.
IsProxy
Gets whether this element is a proxy element or a fully initialized element.
IsSelfClosing
Gets whether the element is self-closing (<foo />).
IsTestRegion
Gets whether the element is a test region or not. This function has been added for performance reasons. We don't want to call the ElementType property since it will trigger the full initialization of types.
MatchingClosingTag
Gets the element's closing tag if it is a begin tag and not self-closing.
Declaration
public Element MatchingClosingTag { get; set; }
Property Value
NameAttributeValue
Gets the value of the attribute ('name') if present on this tag
OuterMarkup
Gets the OuterMarkup of this element.
Example:
<foo id="1"><bar></bar></foo>
If foo is this element then outerMarkup=<foo id="1"><bar></bar></foo>
OwnerBrowser
Gets the owner browser of this element.
Declaration
[Browsable(false)]
public Browser OwnerBrowser { get; }
Property Value
Parent
Gets the Parent element.
ParsedElement
Returns the raw parsed element.
Declaration
public ParsedElement ParsedElement { get; }
Property Value
The raw parsed element
Implements
ParsingType
Gets the parsing type set by the parser. (Markup, LiteralText, Comment..etc)
Declaration
public ParsedElementType ParsingType { get; }
Property Value
TagName
Gets the tagName of the the element
TagNameIndex
Gets the tagName occurrence of this element.
TechnologyType
Get the technology type.
Declaration
public TechnologyType TechnologyType { get; }
Property Value
Implements
TextContent
Gets this element's inner text content without recursing through all its nested children for text.
Methods
AddChild(Element)
Add a child element to this element.
Declaration
public virtual void AddChild(Element child)
Parameters
child
The child to add.
Remarks
This method will only add elements of ParsingType=Markup to the Children collection. ChildNodes collection will contain a complete list of elements of all types. (i.e. Comment,TextLiteral ...etc).
AddChildNode(ITargetElement)
Add this node as a child node.
Declaration
public void AddChildNode(ITargetElement element)
Parameters
element
The element to add as a child
Implements
As<TControl>()
Returns this elements as a strongly-typed control of type TControl.
Declaration
public TControl As<TControl>() where TControl : Control, new()
Returns
TControl
The control object.
Capture()
Captures the image of current element.
Declaration
public Bitmap Capture()
Returns
The image of current element.
Implements
CaptureImage()
Captures the image of curent element with scaling and OS information.
Declaration
public ElementImage CaptureImage()
Returns
ElementsImageData object of curent Element
Implements
CastIncludingAncestors<TControl>(int)
Checks the current element and its ancestors for specified control and returns a strongly-typed control of type TControl.
Declaration
public TControl CastIncludingAncestors<TControl>(int depth = 5) where TControl : Control, new()
Parameters
depth
Maximum number of ancestor to check.
Returns
TControl
The control object.
ContainsAttribute(iAttribute, bool, StringComparison, bool)
Whether a certain attribute is contained in this element
Declaration
public bool ContainsAttribute(iAttribute attribute, bool usePartialAttributeValue, StringComparison comparison, bool matchQuotes)
Parameters
attribute
The attribute to compare.
usePartialAttributeValue
Whether to use partinal values of the attribute values.
comparison
Comparison type.
matchQuotes
Whether to match the quotes or not. This only applied when UsePartialAttributeValue is false.
Returns
True/False Whether the attribute is contained or not.
ContainsAttribute(string)
True/False whether this element contains a specific attribute name.
CreateLight(string, int)
Create an Element object with a specific tagname and index.
Equals(object)
Defines how two Elements should be compared.
FriendlyName()
Constructs a friendly name that represents this element.
Declaration
public string FriendlyName()
Returns
The string representation of this element.
GetAttribute(string)
Find a specific attribute by name and returns it. (case-insensitive)
Declaration
public iAttribute GetAttribute(string name)
Parameters
name
The name of the attribute to get.
Returns
The attribute or null if the attribute was not found.
GetAttribute(string, bool)
Finds a specific attribute name in the Element list of attributes and returns its object
Declaration
public iAttribute GetAttribute(string name, bool ignoreCase)
Parameters
name
The name of the attribute to find.
ignoreCase
Ignore case when searching.
Returns
The attribute object or null if the attribute is not found.
GetAttributeValueOrEmpty(string)
Gets the value of the attribute or a String.Empty if attribute does not exist.
GetChildren()
Get the children of this node.
Declaration
public ITargetElement[] GetChildren()
Returns
The list of children as an array.
Implements
GetHashCode()
Get the hash code for this Element.
Declaration
public override int GetHashCode()
Returns
The hash code.
Overrides
GetHostParent()
Returns the FRAME or IFRAME element containing this element's document, if one exists.
Declaration
public ITargetElement GetHostParent()
Returns
The parent IFrame element this element is hosted in.
Implements
GetNextSibling()
Get the next sibling of this node. If this node is the last sibling, will return null.
GetParent()
Get the parent of this node.
Declaration
public ITargetElement GetParent()
Returns
The parent node.
Implements
GetPreservedInnerText(bool)
Same as InnerText but will respect any whitespaces between the tags.
GetPreviousSibling()
Get the previous sibiling of this node. If this node is the first sibling, will return null.
Declaration
public Element GetPreviousSibling()
Returns
The previous sibling
GetRectangle()
Gets the element rectangle. (X,Y) and width, height as it appears on browser and screen. Takes into account any scrolling.
Declaration
public virtual Rectangle GetRectangle()
Returns
The rectangle object of this element.
Implements
GetStringPresentation()
Get the string representation of current element.
Declaration
public string GetStringPresentation()
Returns
The string representation of current element.
Implements
GetTextContentRecursive(params string[])
Gets the text content of this element, recursing only into the listed tags
GetUniqueHashCode()
Calculates the hash code for this element.
GetValue<T>(string)
Get a property value on this element.
Declaration
public virtual T GetValue<T>(string propertyName)
Parameters
propertyName
The property name.
Returns
T
The property value returned as type T.
GetValue<T>(string, T)
Get a property value on this element.
Declaration
public virtual T GetValue<T>(string propertyName, T defaultValue)
Parameters
propertyName
The property name.
defaultValue
T
The return value, if the property has no value (is null or the empty string)
Returns
T
The property value returned as type T.
GetValue<T>(string, bool)
Get a property value on this element.
Declaration
[Obsolete]
public virtual T GetValue<T>(string propertyName, bool isJsWrappedObject)
Parameters
propertyName
The property name.
isJsWrappedObject
True/False whether you are accessing an extended wrapperd JS object. [Needed for Firefox only]
Returns
T
The property value returned as type T.
GetValue<T>(string, bool, T)
Get a property value on this element.
Declaration
[Obsolete]
public virtual T GetValue<T>(string propertyName, bool isJsWrappedObject, T defaultValue)
Parameters
propertyName
The property name.
isJsWrappedObject
True/False whether you are accessing an extended wrapped JS object. [Needed for Firefox only]
defaultValue
T
The return value, if the property has no value (is null or the empty string)
Returns
T
The property value returned as type T.
IsFrame()
Gets whether this element represents an iframe or frame
Declaration
public FrameInfo IsFrame()
Returns
Return the FrameInfo of the frame if is a frame, else will return null
IsFrame(bool, bool)
Gets whether this element represents an iframe or frame
Declaration
public FrameInfo IsFrame(bool makeAbsolute, bool stripFinalBrowserSegment = false)
Parameters
makeAbsolute
Whether to force the FrameInfo's Src to be an absolute URI
stripFinalBrowserSegment
When used in conjunction with makeAbsolute, this will strip the final path segment from the owning browser's URL before concatenating the frame's src.
Returns
Return the FrameInfo of the frame if is a frame, else will return null
Match(IFindExpression)
Match this expression against element.
Declaration
public bool Match(IFindExpression findExpr)
Parameters
findExpr
The expression to use.
Returns
Returns true/false
Implements
Refresh()
Using the FindParamsUsed and the TestRegionIdUsed to find this element last, this methods will attempt to re-find this element in the new DOM tree.
Declaration
public virtual void Refresh()
Implements
Refresh(bool)
Using the FindParamsUsed and the TestRegionIdUsed to find this element last, this methods will attempt to re-find this element in the new DOM tree.
Declaration
public virtual void Refresh(bool forceDomTreeRefresh)
Parameters
forceDomTreeRefresh
Force a Browser/Plugin refresh before attempting to refine this element.
SetClosingTag(ITargetElement)
Set the matching closing tag.
Declaration
public void SetClosingTag(ITargetElement closingElement)
Parameters
closingElement
The closing tag
Implements
SetDepth(int)
Sets the hierarchical depth of this element.
Declaration
public void SetDepth(int depth)
Parameters
depth
The required depth
Implements
SetParent(ITargetElement)
Sets the parent of this Element.
Declaration
public void SetParent(ITargetElement parent)
Parameters
parent
The parent element.
Implements
SetValue<T>(string, T)
Set a property to a value on this element.
Declaration
public virtual void SetValue<T>(string propertyName, T value)
Parameters
propertyName
The property name.
value
T
The value.
SetValue<T>(string, T, bool)
Set a property to a value on this element.
Declaration
public virtual void SetValue<T>(string propertyName, T value, bool isJsWrappedObject)
Parameters
propertyName
The property name.
value
T
The value.
isJsWrappedObject
True/False whether you are accessing an extended wrapperd JS object. [Needed for Firefox only]
ToString()
String representation of an Element.
Declaration
public override string ToString()
Returns
The string representation.
Overrides