PageFactory InitElements T  Method (IWebDriver)WebDriver
Initializes the elements in the Page Object with the given type.

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

public static T InitElements<T>(
	IWebDriver driver
)
Type Parameters

T
The OnlineType of the Page Object class.

Return Value

An instance of the Page Object class with the elements initialized.
Exceptions

ExceptionCondition
OnlineSystem ArgumentException thrown if no constructor to the class can be found with a single IWebDriver argument

-or-

if a field or property decorated with the FindsByAttribute is not of type IWebElement or IList{IWebElement}.
Remarks

The class used in the T argument must have a public constructor that takes a single argument of type IWebDriver. This helps to enforce best practices of the Page Object pattern, and encapsulates the driver into the Page Object so that it can have no external WebDriver dependencies.
See Also