By ClassWebDriver
Provides a mechanism by which to find elements within a document.
Inheritance Hierarchy

SystemObject
  OpenQA.SeleniumBy
    OpenQA.Selenium.Support.PageObjectsByAll
    OpenQA.Selenium.Support.PageObjectsByChained
    OpenQA.Selenium.Support.PageObjectsByIdOrName

Namespace: OpenQA.Selenium
Assembly: WebDriver (in WebDriver.dll) Version: 3.1.0
Syntax

[SerializableAttribute]
public class By

The By type exposes the following members.

Constructors

  NameDescription
Protected methodBy
Initializes a new instance of the By class.
Protected methodBy(FuncISearchContext, IWebElement, FuncISearchContext, ReadOnlyCollectionIWebElement)
Initializes a new instance of the By class using the given functions to find elements.
Top
Properties

  NameDescription
Protected propertyDescription
Gets or sets the value of the description for this By class instance.
Protected propertyFindElementMethod
Gets or sets the method used to find a single element matching specified criteria.
Protected propertyFindElementsMethod
Gets or sets the method used to find all elements matching specified criteria.
Top
Methods

  NameDescription
Public methodStatic memberClassName
Gets a mechanism to find elements by their CSS class.
Public methodStatic memberCssSelector
Gets a mechanism to find elements by their cascading style sheet (CSS) selector.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Overrides ObjectEquals(Object).)
Protected methodFinalize
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFindElement
Finds the first element matching the criteria.
Public methodFindElements
Finds all elements matching the criteria.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Overrides ObjectGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberId
Gets a mechanism to find elements by their ID.
Public methodStatic memberLinkText
Gets a mechanism to find elements by their link text.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberName
Gets a mechanism to find elements by their name.
Public methodStatic memberPartialLinkText
Gets a mechanism to find elements by a partial match on their link text.
Public methodStatic memberTagName
Gets a mechanism to find elements by their tag name.
Public methodToString
Gets a string representation of the finder.
(Overrides ObjectToString.)
Public methodStatic memberXPath
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.
Top
Operators

  NameDescription
Public operatorStatic memberEquality
Determines if two By instances are equal.
Public operatorStatic memberInequality
Determines if two By instances are unequal.
Top
Remarks

It is possible to create your own locating mechanisms for finding documents. In order to do this,subclass this class and override the protected methods. However, it is expected that that all subclasses rely on the basic finding mechanisms provided through static methods of this class. An example of this can be found in OpenQA.Support.ByIdOrName
See Also

Reference