FindsByAttribute ClassWebDriver
Marks program elements with methods by which to find a corresponding element on the page. Used in conjunction with the PageFactory, it allows you to quickly create Page Objects.
Inheritance Hierarchy

OnlineSystem Object
  OnlineSystem Attribute
    OpenQA.Selenium.Support.PageObjects FindsByAttribute

Namespace: OpenQA.Selenium.Support.PageObjects
Assembly: WebDriver.Support (in WebDriver.Support.dll) Version: 2.35.0.0 (2.35.0.0)
Syntax

public sealed class FindsByAttribute : Attribute, 
	IComparable
Remarks

You can use this attribute by specifying the How and Using properties to indicate how to find the elements. This attribute can be used to decorate fields and properties in your Page Object classes. The OnlineType of the field or property must be either IWebElement or IList{IWebElement}. Any other type will throw an OnlineArgumentException when InitElements(ISearchContext, Object) is called.

[FindsBy(How = How.Name, Using = "myElementName")]
public IWebElement foundElement;

[FindsBy(How = How.TagName, Using = "a")]
public IList{IWebElement} allLinks;

You can also use multiple instances of this attribute to find an element that may meet one of multiple criteria. When using multiple instances, you can specify the order in which the criteria is matched by using the Priority property.

// Will find the element with the name attribute matching the first of "anElementName" 
// or "differentElementName".
[FindsBy(How = How.Name, Using = "anElementName", Priority = 0)]
[FindsBy(How = How.Name, Using = "differentElementName", Priority = 1)]
public IWebElement thisElement;

See Also