HtmlElement.Net
Public Member Functions | Properties | List of all members
HtmlElements.Elements.HtmlElement Class Reference

Models HTML DOM element providing access to common attributes and properties More...

Inherits HtmlElements.WebDriverWrapper, and HtmlElements.Elements.IHtmlElement.

Inherited by HtmlElements.Elements.HtmlControl, HtmlElements.Elements.HtmlForm, HtmlElements.Elements.HtmlFrame, HtmlElements.Elements.HtmlImage, HtmlElements.Elements.HtmlLabel, HtmlElements.Elements.HtmlLink, and HtmlElements.Elements.HtmlTable.

Public Member Functions

 HtmlElement (IWebElement webElement)
 
void Clear ()
 Clears the content of this element. More...
 
void SendKeys (string text)
 Simulates typing text into the element. More...
 
void Submit ()
 Submits this element to the web server. More...
 
void Click ()
 Clicks this element. More...
 
string GetAttribute (string attributeName)
 Gets the value of the specified attribute for this element. More...
 
string GetProperty (string propertyName)
 Gets the value of a JavaScript property of this element. More...
 
string GetCssValue (string propertyName)
 Gets the value of a CSS property of this element. More...
 
void EnterText (string text)
 Replace existing text input with provided. More...
 
TPage Open< TPage > ()
 Clicks on a wrapped WebElement and creates new page object instance of given type. More...
 
TPage OpenInNewWindow< TPage > ()
 Clicks on wrapped WebElement, waits until new window is opened and switches to it. More...
 
- Public Member Functions inherited from HtmlElements.WebDriverWrapper
object ExecuteScript (string script, params object[] args)
 Executes JavaScript in the context of the currently selected frame or window. More...
 
object ExecuteAsyncScript (string script, params object[] args)
 Executes JavaScript asynchronously in the context of the currently selected frame or window. More...
 
ReadOnlyCollection< IWebElement > FindElements (By @by)
 Finds all IWebElements within the current context using the given mechanism. More...
 
IWebElement FindElement (By @by)
 Finds the first T:OpenQA.Selenium.IWebElement using the given method. More...
 
TElement FindElement< TElement > (By @by)
 Finds the first IWebElement using given method and creates a page object of given type wrapping the element. More...
 
IList< TElement > FindElements< TElement > (By @by)
 Finds all IWebElements within the current context using the given mechanism and creates page objects wrapping it. More...
 
override string ToString ()
 Describes actual page object type and wrapped search context. More...
 

Properties

string Class [get, set]
 Gets or sets 'class' attribute of the underlying DOM element or null if it does not exist More...
 
IWebElement FirstChild [get]
 First child node of the web element, as a web element More...
 
string Id [get, set]
 Gets or sets 'id' attribute of the underlying DOM element or null if it does not exist More...
 
string InnerHtml [get, set]
 HTML content of an element More...
 
IWebElement LastChild [get]
 Last child node of the current element, as a web element More...
 
string Name [get, set]
 Gets or sets 'name' attribute of the underlying DOM element or null if it does not exist More...
 
IWebElement NextSibling [get]
 The next node of current web element, in the same tree level More...
 
IWebElement ParentNode [get]
 A WebElement, representing the parent node of current element, or null if it has no parent More...
 
IWebElement PreviousSibling [get]
 A previous node of current web element, in the same tree level More...
 
string Style [get, set]
 Gets or sets 'style' attribute of the underlying DOM element or null if it does not exist More...
 
string TextContent [get, set]
 Returns or sets the text from the element. On returning text, this property returns the value of all text nodes within the element node. On setting text, this property removes all child nodes and replaces them with a single text node. More...
 
string Title [get, set]
 Gets or sets 'title' attribute of the underlying DOM element or null if it does not exist More...
 
IWebElement WrappedElement [get]
 Returns underlying web element wrapped by current HtmlElement More...
 
string TagName [get]
 Gets the tag name of this element. More...
 
string Text [get]
 Gets the innerText of this element, without any leading or trailing whitespace, and with other whitespace collapsed. More...
 
bool Enabled [get]
 Gets a value indicating whether or not this element is enabled. More...
 
bool Selected [get]
 Gets a value indicating whether or not this element is selected. More...
 
Point Location [get]
 Gets a Point object containing the coordinates of the upper-left corner of this element relative to the upper-left corner of the page. More...
 
Size Size [get]
 Gets object containing the height and width of this element. More...
 
bool Displayed [get]
 Gets a value indicating whether or not this element is displayed. More...
 
- Properties inherited from HtmlElements.WebDriverWrapper
IPageObjectFactory PageObjectFactory [get]
 Gets the page object factory used to initialize current page object instance. More...
 
IWebDriver WrappedDriver [get]
 Gets the T:OpenQA.Selenium.IWebDriver wrapped by current page object instance. More...
 

Additional Inherited Members

- Protected Member Functions inherited from HtmlElements.WebDriverWrapper
 WebDriverWrapper (ISearchContext webDriverOrWrapper)
 Initializes wrapper converting provided object to WebDriver More...
 

Detailed Description

Models HTML DOM element providing access to common attributes and properties

Member Function Documentation

◆ Clear()

void HtmlElements.Elements.HtmlElement.Clear ( )

Clears the content of this element.

If this element is a text entry element, the method will clear the value. It has no effect on other elements. Text entry elements are defined as elements with INPUT or TEXTAREA tags.

◆ Click()

void HtmlElements.Elements.HtmlElement.Click ( )

Clicks this element.

Click this element. If the click causes a new page to load, the method will attempt to block until the page has loaded. After calling the method, you should discard all references to this element unless you know that the element and the page will still be present.
Otherwise, any further operations performed on this element will have an undefined behavior. If this element is not clickable, then this operation is ignored. This allows you to simulate a users to accidentally missing the target when clicking.

◆ EnterText()

void HtmlElements.Elements.HtmlElement.EnterText ( string  text)

Replace existing text input with provided.

Parameters
textText to enter

◆ GetAttribute()

string HtmlElements.Elements.HtmlElement.GetAttribute ( string  attributeName)

Gets the value of the specified attribute for this element.

Parameters
attributeNameThe name of the attribute.
Returns
The attribute's current value. Returns a null if the value is not set.

The method will return the current value of the attribute, even if the value has been modified after the page has been loaded. Note that the value of the following attributes will be returned even if there is no explicit attribute on the element: Attribute nameValue returned if not explicitly specified.

◆ GetCssValue()

string HtmlElements.Elements.HtmlElement.GetCssValue ( string  propertyName)

Gets the value of a CSS property of this element.

Parameters
propertyNameThe name of the CSS property to get the value of.
Returns
The value of the specified CSS property.

The value returned by the method is likely to be unpredictable in a cross-browser environment.
Color values should be returned as hex strings. For example, a "background-color" property set as "green" in the HTML source, will return "#008000" for its value.

◆ GetProperty()

string HtmlElements.Elements.HtmlElement.GetProperty ( string  propertyName)

Gets the value of a JavaScript property of this element.

Parameters
propertyName
Returns
The JavaScript property's current value. Returns a null if the value is not set or the property does not exist. /returns>
Exceptions
StaleElementReferenceExceptionThrown when the target element is no longer valid in the document DOM.

◆ Open< TPage >()

TPage HtmlElements.Elements.HtmlElement.Open< TPage > ( )

Clicks on a wrapped WebElement and creates new page object instance of given type.

Template Parameters
TPageThe type of page object being created.
Returns
New page object instance.

◆ OpenInNewWindow< TPage >()

TPage HtmlElements.Elements.HtmlElement.OpenInNewWindow< TPage > ( )

Clicks on wrapped WebElement, waits until new window is opened and switches to it.

Template Parameters
TPageType of page object being created.
Returns
New page object instance.

◆ SendKeys()

void HtmlElements.Elements.HtmlElement.SendKeys ( string  text)

Simulates typing text into the element.

Parameters
textThe text to type into the element.

The text to be typed may include special characters like arrow keys, backspaces, function keys, and so on. Valid special keys are defined in Keys.

◆ Submit()

void HtmlElements.Elements.HtmlElement.Submit ( )

Submits this element to the web server.

If this current element is a form, or an element within a form, then this will be submitted to the web server. If this causes the current page to change, then this method will block until the new page is loaded.

Property Documentation

◆ Class

string HtmlElements.Elements.HtmlElement.Class
getset

Gets or sets 'class' attribute of the underlying DOM element or null if it does not exist

◆ Displayed

bool HtmlElements.Elements.HtmlElement.Displayed
get

Gets a value indicating whether or not this element is displayed.

◆ Enabled

bool HtmlElements.Elements.HtmlElement.Enabled
get

Gets a value indicating whether or not this element is enabled.

The property will generally return true for everything except explicitly disabled input elements.

◆ FirstChild

IWebElement HtmlElements.Elements.HtmlElement.FirstChild
get

First child node of the web element, as a web element

◆ Id

string HtmlElements.Elements.HtmlElement.Id
getset

Gets or sets 'id' attribute of the underlying DOM element or null if it does not exist

◆ InnerHtml

string HtmlElements.Elements.HtmlElement.InnerHtml
getset

HTML content of an element

◆ LastChild

IWebElement HtmlElements.Elements.HtmlElement.LastChild
get

Last child node of the current element, as a web element

◆ Location

Point HtmlElements.Elements.HtmlElement.Location
get

Gets a Point object containing the coordinates of the upper-left corner of this element relative to the upper-left corner of the page.

◆ Name

string HtmlElements.Elements.HtmlElement.Name
getset

Gets or sets 'name' attribute of the underlying DOM element or null if it does not exist

◆ NextSibling

IWebElement HtmlElements.Elements.HtmlElement.NextSibling
get

The next node of current web element, in the same tree level

◆ ParentNode

IWebElement HtmlElements.Elements.HtmlElement.ParentNode
get

A WebElement, representing the parent node of current element, or null if it has no parent

◆ PreviousSibling

IWebElement HtmlElements.Elements.HtmlElement.PreviousSibling
get

A previous node of current web element, in the same tree level

◆ Selected

bool HtmlElements.Elements.HtmlElement.Selected
get

Gets a value indicating whether or not this element is selected.

This operation only applies to input elements such as checkboxes, options in a select element and radio buttons.

◆ Size

Size HtmlElements.Elements.HtmlElement.Size
get

Gets object containing the height and width of this element.

◆ Style

string HtmlElements.Elements.HtmlElement.Style
getset

Gets or sets 'style' attribute of the underlying DOM element or null if it does not exist

◆ TagName

string HtmlElements.Elements.HtmlElement.TagName
get

Gets the tag name of this element.

◆ Text

string HtmlElements.Elements.HtmlElement.Text
get

Gets the innerText of this element, without any leading or trailing whitespace, and with other whitespace collapsed.

◆ TextContent

string HtmlElements.Elements.HtmlElement.TextContent
getset

Returns or sets the text from the element. On returning text, this property returns the value of all text nodes within the element node. On setting text, this property removes all child nodes and replaces them with a single text node.

◆ Title

string HtmlElements.Elements.HtmlElement.Title
getset

Gets or sets 'title' attribute of the underlying DOM element or null if it does not exist

◆ WrappedElement

IWebElement HtmlElements.Elements.HtmlElement.WrappedElement
get

Returns underlying web element wrapped by current HtmlElement