A base class representing an HTML element on a page.
public class WebElement : IWebElement, ISearchContext, IFindsElement, IWrapsDriver, ILocatable, ITakesScreenshot
WebElement
Initializes a new instance of the WebElement class.
public WebElement(WebDriver parentDriver, string id)
Parameters
parentDriver
WebDriver
The WebDriver instance that is driving this element.
id
string
The ID value provided to identify the element.
If parentDriver
or id
are null.
The property name that represents a web element in the wire protocol.
public const string ElementReferencePropertyName = "element-6066-11e4-a52e-4f735466cecf"
Field Value
Gets the computed accessible label of this element.
public virtual string ComputedAccessibleLabel { get; }
Property Value
Gets the computed ARIA role for this element.
public virtual string ComputedAccessibleRole { get; }
Property Value
Gets the coordinates identifying the location of this element using various frames of reference.
public virtual ICoordinates Coordinates { get; }
Property Value
Gets a value indicating whether or not this element is displayed.
public virtual bool Displayed { get; }
Property Value
Thrown when the target element is no longer valid in the document DOM.
Gets a value indicating whether or not this element is enabled.
public virtual bool Enabled { get; }
Property Value
Thrown when the target element is no longer valid in the document DOM.
Gets the ID of the element
protected string Id { get; }
Property Value
Gets a Point object containing the coordinates of the upper-left corner of this element relative to the upper-left corner of the page.
public virtual Point Location { get; }
Property Value
Thrown when the target element is no longer valid in the document DOM.
Gets the point where the element would be when scrolled into view.
public virtual Point LocationOnScreenOnceScrolledIntoView { get; }
Property Value
Gets a value indicating whether or not this element is selected.
public virtual bool Selected { get; }
Property Value
Thrown when the target element is no longer valid in the document DOM.
Gets a Size object containing the height and width of this element.
public virtual Size Size { get; }
Property Value
Thrown when the target element is no longer valid in the document DOM.
Gets the tag name of this element.
public virtual string TagName { get; }
Property Value
Thrown when the target element is no longer valid in the document DOM.
Gets the innerText of this element, without any leading or trailing whitespace, and with other whitespace collapsed.
public virtual string Text { get; }
Property Value
Thrown when the target element is no longer valid in the document DOM.
Gets the IWebDriver driving this element.
public IWebDriver WrappedDriver { get; }
Property Value
Clears the content of this element.
public virtual void Clear()
Exceptions
Thrown when the target element is no longer valid in the document DOM.
Clicks this element.
public virtual void Click()
Exceptions
Thrown when the target element is not enabled.
Thrown when the target element is no longer valid in the document DOM.
Compares if two elements are equal
public override bool Equals(object? obj)
Parameters
obj
object
Object to compare against
A boolean if it is equal or not
Executes a command on this element using the specified parameters.
protected virtual Response Execute(string commandToExecute, Dictionary<string, object>? parameters)
Parameters
commandToExecute
string
The DriverCommand to execute against this element.
parameters
Dictionary<string, object>
A Dictionary<TKey, TValue> containing names and values of the parameters for the command.
The Response object containing the result of the command execution.
Finds the first IWebElement using the given method.
public virtual IWebElement FindElement(By by)
Parameters
by
By
The locating mechanism to use.
The first matching IWebElement on the current context.
If by
is null.
If no element matches the criteria.
Finds a child element matching the given mechanism and value.
public virtual IWebElement FindElement(string mechanism, string value)
Parameters
mechanism
string
The mechanism by which to find the element.
value
string
The value to use to search for the element.
The first IWebElement matching the given criteria.
Finds all IWebElements within the current context using the given mechanism.
public virtual ReadOnlyCollection<IWebElement> FindElements(By by)
Parameters
by
By
The locating mechanism to use.
A ReadOnlyCollection<T> of all WebElements matching the current criteria, or an empty list if nothing matches.
Finds all child elements matching the given mechanism and value.
public virtual ReadOnlyCollection<IWebElement> FindElements(string mechanism, string value)
Parameters
mechanism
string
The mechanism by which to find the elements.
value
string
The value to use to search for the elements.
A collection of all of the IWebElements matching the given criteria.
Gets the value of the specified attribute or property for this element.
public virtual string? GetAttribute(string attributeName)
Parameters
attributeName
string
The name of the attribute or property.
The attribute's or property's current value. Returns a null if the value is not set.
Thrown when the target element is no longer valid in the document DOM.
Gets the value of a CSS property of this element.
public virtual string GetCssValue(string propertyName)
Parameters
propertyName
string
The name of the CSS property to get the value of.
The value of the specified CSS property.
Thrown when the target element is no longer valid in the document DOM.
Gets the value of a declared HTML attribute of this element.
public virtual string? GetDomAttribute(string attributeName)
Parameters
attributeName
string
The name of the HTML attribute to get the value of.
The HTML attribute's current value. Returns a null if the value is not set or the declared attribute does not exist.
Thrown when the target element is no longer valid in the document DOM.
Gets the value of a JavaScript property of this element.
public virtual string? GetDomProperty(string propertyName)
Parameters
propertyName
string
The name of the JavaScript property to get the value of.
The JavaScript property's current value. Returns a null if the value is not set or the property does not exist.
Thrown when the target element is no longer valid in the document DOM.
Method to get the hash code of the element
public override int GetHashCode()
Returns
Integer of the hash code for the element
Gets a Screenshot object representing the image of this element on the screen.
public virtual Screenshot GetScreenshot()
Returns
A Screenshot object containing the image.
Gets the representation of an element's shadow root for accessing the shadow DOM of a web component.
public virtual ISearchContext GetShadowRoot()
Returns
A shadow root representation.
Thrown when the target element is no longer valid in the document DOM.
Thrown when this element does not have a shadow root.
Simulates typing text into the element.
public virtual void SendKeys(string text)
Parameters
text
string
The text to type into the element.
Thrown when the target element is not enabled.
Thrown when the target element is no longer valid in the document DOM.
Submits this element to the web server.
public virtual void Submit()
Exceptions
Thrown when the target element is no longer valid in the document DOM.
Returns a string that represents the current WebElement.
public override string ToString()
Returns
A string that represents the current WebElement.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4