ApiExtensions
A set of useful extension methods when dealing with the DOM.
Adds the specified class name(s) for all elements in the given
collection.
Inserts the nodes generated from the given HTML code after
each element of the provided elements.
Gets the ancestor nodes of the given child.
Gets the ancestor nodes of the given child.
Appends the nodes generated from the given HTML code to each
element of the provided elements.
public static TElement AppendElement<TElement>(this INode parent, TElement element) where TElement : IElement
Inserts a node as the last child node of this element.
public static T Attr<T>(this T elements, string attributeName, string attributeValue) where T : IEnumerable<IElement>
Sets the specified attribute name to the specified value for all
elements in the given collection.
public static T Attr<T>(this T elements, IEnumerable<KeyValuePair<string, string>> attributes) where T : IEnumerable<IElement>
Sets the specified attribute name to the specified value for all
elements in the given collection.
Sets the specified attribute name to the specified value for all
elements in the given collection.
public static IEnumerable<string> Attr<T>(this T elements, string attributeName) where T : IEnumerable<IElement>
Gets the values of the specified attribute for all elements in the
given collection.
public static Task<Event> AwaitEvent<TEventTarget>(this TEventTarget node, string eventName) where TEventTarget : IEventTarget
Returns a task that is completed once the event is fired.
Inserts the nodes generated from the given HTML code before
each element of the provided elements.
Creates an element of the given type or throws an exception, if
there is no such type.
public static T Css<T>(this T elements, string propertyName, string propertyValue) where T : IEnumerable<IElement>
Extends the CSS of the given elements with the specified
declarations.
public static T Css<T>(this T elements, IEnumerable<KeyValuePair<string, string>> properties) where T : IEnumerable<IElement>
Extends the CSS of the given elements with the specified
declarations.
Extends the CSS of the given elements with the specified
declarations.
Gets the descendent nodes of the given parent.
Gets the descendent nodes of the given parent.
Empties all provided elements.
Reduces the elements to the one at the given index, if any.
Reduces the elements to the ones with even index.
Gets all downloads associated with resources of the document.
Reduces the elements to the ones above the given index.
Checks if any element in the given collection has the given
class(es).
Gets the inner HTML of the given element.
Sets the inner HTML of the given elements.
Gets the index of the given item in the list of elements.
public static TElement InsertElement<TElement>(this INode parent, TElement newElement, INode referenceElement) where TElement : IElement
Inserts the newElement immediately before the referenceElement.
Reduces the elements to the ones below the given index.
public static Task<IDocument> Navigate<TElement>(this TElement element) where TElement : IUrlUtilities, IElement
Navigates to the hyper reference given by the provided element
without any possibility for cancellation.
public static Task<IDocument> Navigate<TElement>(this TElement element, CancellationToken cancel) where TElement : IUrlUtilities, IElement
Navigates to the hyper reference given by the provided element.
Reduces the elements to the ones with odd index.
Prepends the nodes generated from the given HTML code to each
element of the provided elements.
public static TElement QuerySelector<TElement>(this IParentNode parent, string selectors) where TElement : IElement
Returns the first element matching the selectors with the provided
type, or null.
public static IEnumerable<TElement> QuerySelectorAll<TElement>(this IParentNode parent, string selectors) where TElement : IElement
Returns a list of elements matching the selectors with the
provided type.
Removes the specified class name(s) for all elements in the given
collection.
public static TElement RemoveElement<TElement>(this INode parent, TElement element) where TElement : IElement
Removes a child node from the current element, which must be a
child of the current node.
public static void SetFieldValues(this IHtmlFormElement form, IDictionary<string, string> fields, bool createInputIfNotFound = false)
Set the field values of given form by using the dictionary which
contains name value pairs of input fields.
Submits the given form by decomposing the object into a dictionary
that contains its properties as name value pairs.
public static Task<IDocument> Submit(this IHtmlFormElement form, IDictionary<string, string> fields, bool createInputIfNotFound = false)
Submits the given form by using the dictionary which contains name
value pairs of input fields to submit.
Gets the content text of the given DOM element.
Sets the text content of the given elements.
Toggles the specified class name(s) for all elements in the given
collection.
Wraps the given elements in the inner most element of the tree
generated form the provided HTML code.
Wraps all elements in the inner most element of the tree
generated form the provided HTML code. The tree is appended before
the first element of the given list.
Wraps the content of the given elements in the inner most element
of the tree generated form the provided HTML code.