A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://seleniumhq.github.io/selenium/docs/api/dotnet/webdriver/OpenQA.Selenium.By.html below:

Class By

Class By
Namespace
OpenQA.Selenium
Assembly
WebDriver.dll

Provides a mechanism by which to find elements within a document.

[Serializable]
public class By
Inheritance

By

Derived
Inherited Members
Constructors By()

Initializes a new instance of the By class.

By(Func<ISearchContext, IWebElement>, Func<ISearchContext, ReadOnlyCollection<IWebElement>>)

Initializes a new instance of the By class using the given functions to find elements.

protected By(Func<ISearchContext, IWebElement> findElementMethod, Func<ISearchContext, ReadOnlyCollection<IWebElement>> findElementsMethod)
Parameters
findElementMethod Func<ISearchContext, IWebElement>

A function that takes an object implementing ISearchContext and returns the found IWebElement.

findElementsMethod Func<ISearchContext, ReadOnlyCollection<IWebElement>>

A function that takes an object implementing ISearchContext and returns a ReadOnlyCollection<T> of the foundIWebElements. IWebElements/>.

By(string, string)

Initializes a new instance of the By class using the specified mechanism and criteria for finding elements.

protected By(string mechanism, string criteria)
Parameters
mechanism string

The mechanism to use in finding elements.

criteria string

The criteria to use in finding elements.

Properties Criteria

Gets the value of the criteria for this By class instance.

public string Criteria { get; }
Property Value
string
Description

Gets or sets the value of the description for this By class instance.

protected string Description { get; set; }
Property Value
string
FindElementMethod

Gets or sets the method used to find a single element matching specified criteria, or throws NoSuchElementException if no element is found.

protected Func<ISearchContext, IWebElement>? FindElementMethod { get; set; }
Property Value
Func<ISearchContext, IWebElement>
FindElementsMethod

Gets or sets the method used to find all elements matching specified criteria.

protected Func<ISearchContext, ReadOnlyCollection<IWebElement>>? FindElementsMethod { get; set; }
Property Value
Func<ISearchContext, ReadOnlyCollection<IWebElement>>
Mechanism

Gets the value of the mechanism for this By class instance.

public string Mechanism { get; }
Property Value
string
Methods ClassName(string)

Gets a mechanism to find elements by their CSS class.

public static By ClassName(string classNameToFind)
Parameters
classNameToFind string

The CSS class to find.

Returns
By

A By object the driver can use to find the elements.

Exceptions
ArgumentNullException

If classNameToFind is null.

CssSelector(string)

Gets a mechanism to find elements by their cascading style sheet (CSS) selector.

public static By CssSelector(string cssSelectorToFind)
Parameters
cssSelectorToFind string

The CSS selector to find.

Returns
By

A By object the driver can use to find the elements.

Exceptions
ArgumentNullException

If cssSelectorToFind is null.

Equals(object?)

Determines whether the specified Object is equal to the current Object.

public override bool Equals(object? obj)
Parameters
obj object

The Object to compare with the current Object.

Returns
bool

true if the specified Object is equal to the current Object; otherwise, false.

FindElement(ISearchContext)

Finds the first element matching the criteria.

public virtual IWebElement FindElement(ISearchContext context)
Parameters
context ISearchContext

An ISearchContext object to use to search for the elements.

Returns
IWebElement

The first matching IWebElement on the current context.

Exceptions
NoSuchElementException

If no element matches the criteria.

FindElements(ISearchContext)

Finds all elements matching the criteria.

public virtual ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
Parameters
context ISearchContext

An ISearchContext object to use to search for the elements.

Returns
ReadOnlyCollection<IWebElement>

A ReadOnlyCollection<T> of all WebElements matching the current criteria, or an empty list if nothing matches.

GetHashCode()

Serves as a hash function for a particular type.

public override int GetHashCode()
Returns
int

A hash code for the current Object.

Id(string)

Gets a mechanism to find elements by their ID.

public static By Id(string idToFind)
Parameters
idToFind string

The ID to find.

Returns
By

A By object the driver can use to find the elements.

Exceptions
ArgumentNullException

If idToFind is null.

LinkText(string)

Gets a mechanism to find elements by their link text.

public static By LinkText(string linkTextToFind)
Parameters
linkTextToFind string

The link text to find.

Returns
By

A By object the driver can use to find the elements.

Exceptions
ArgumentNullException

If linkTextToFind is null.

Name(string)

Gets a mechanism to find elements by their name.

public static By Name(string nameToFind)
Parameters
nameToFind string

The name to find.

Returns
By

A By object the driver can use to find the elements.

Exceptions
ArgumentNullException

If nameToFind is null.

PartialLinkText(string)

Gets a mechanism to find elements by a partial match on their link text.

public static By PartialLinkText(string partialLinkTextToFind)
Parameters
partialLinkTextToFind string

The partial link text to find.

Returns
By

A By object the driver can use to find the elements.

Exceptions
ArgumentNullException

If partialLinkTextToFind is null.

TagName(string)

Gets a mechanism to find elements by their tag name.

public static By TagName(string tagNameToFind)
Parameters
tagNameToFind string

The tag name to find.

Returns
By

A By object the driver can use to find the elements.

Exceptions
ArgumentNullException

If tagNameToFind is null.

ToString()

Gets a string representation of the finder.

public override string ToString()
Returns
string

The string displaying the finder content.

XPath(string)

Gets a mechanism to find elements by an XPath query. When searching within a WebElement using xpath be aware that WebDriver follows standard conventions: a search prefixed with "//" will search the entire document, not just the children of this current node. Use ".//" to limit your search to the children of this WebElement.

public static By XPath(string xpathToFind)
Parameters
xpathToFind string

The XPath query to use.

Returns
By

A By object the driver can use to find the elements.

Exceptions
ArgumentNullException

If xpathToFind is null.

Operators operator ==(By?, By?)

Determines if two By instances are equal.

public static bool operator ==(By? one, By? two)
Parameters
one By

One instance to compare.

two By

The other instance to compare.

Returns
bool

true if the two instances are equal; otherwise, false.

operator !=(By?, By?)

Determines if two By instances are unequal.

public static bool operator !=(By? one, By? two)
Parameters
one By

One instance to compare.

two By

The other instance to compare.

Returns
bool

true if the two instances are not equal; otherwise, false.


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