IWebDriver InterfaceWebDriver
Defines the interface through which the user controls the browser.

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

public interface IWebDriver : ISearchContext, 

The IWebDriver type exposes the following members.


Public propertyCurrentWindowHandle
Gets the current window handle, which is an opaque handle to this window that uniquely identifies it within this driver instance.
Public propertyPageSource
Gets the source of the page last loaded by the browser.
Public propertyTitle
Gets the title of the current browser window.
Public propertyUrl
Gets or sets the URL the browser is currently displaying.
Public propertyWindowHandles
Gets the window handles of open browser windows.

Public methodClose
Close the current window, quitting the browser if it is the last window currently open.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Public methodFindElement
Finds the first IWebElement using the given method.
(Inherited from ISearchContext.)
Public methodFindElements
Finds all IWebElements within the current context using the given mechanism.
(Inherited from ISearchContext.)
Public methodManage
Instructs the driver to change its settings.
Public methodNavigate
Instructs the driver to navigate the browser to another location.
Public methodQuit
Quits this driver, closing every associated window.
Public methodSwitchTo
Instructs the driver to send future commands to a different frame or window.
Extension Methods

Public Extension MethodExecuteJavaScript(String, Object)Overloaded.
Executes JavaScript in the context of the currently selected frame or window
(Defined by WebDriverExtensions.)
Public Extension MethodExecuteJavaScriptT(String, Object)Overloaded.
Executes JavaScript in the context of the currently selected frame or window
(Defined by WebDriverExtensions.)
Public Extension MethodTakeScreenshot
Gets a Screenshot object representing the image of the page on the screen.
(Defined by WebDriverExtensions.)

The IWebDriver interface is the main interface to use for testing, which represents an idealized web browser. The methods in this class fall into three categories:
  • Control of the browser itself
  • Selection of IWebElements
  • Debugging aids

Key properties and methods are Url, which is used to load a new web page by setting the property, and the various methods similar to FindElement(By), which is used to find IWebElements.

You use the interface by instantiate drivers that implement of this interface. You should write your tests against this interface so that you may "swap in" a more fully featured browser when there is a requirement for one.

See Also