Interface ITargetLocator
Defines the interface through which the user can locate a given frame or window.
public interface ITargetLocator
Methods
ActiveElement()
Switches to the element that currently has the focus, or the body element if no element with focus can be detected.
IWebElement ActiveElement()
Returns
- IWebElement
An IWebElement instance representing the element with the focus, or the body element if no element with focus can be detected.
Alert()
Switches to the currently active modal dialog for this particular driver instance.
IAlert Alert()
Returns
- IAlert
A handle to the dialog.
DefaultContent()
Selects either the first frame on the page or the main document when a page contains iFrames.
IWebDriver DefaultContent()
Returns
- IWebDriver
An IWebDriver instance focused on the default frame.
Frame(IWebElement)
Select a frame using its previously located IWebElement
IWebDriver Frame(IWebElement frameElement)
Parameters
frameElement
IWebElementThe frame element to switch to.
Returns
- IWebDriver
An IWebDriver instance focused on the specified frame.
Exceptions
- NoSuchFrameException
If the element is neither a FRAME nor an IFRAME element.
- StaleElementReferenceException
If the element is no longer valid.
Frame(int)
Select a frame by its (zero-based) index.
IWebDriver Frame(int frameIndex)
Parameters
frameIndex
intThe zero-based index of the frame to select.
Returns
- IWebDriver
An IWebDriver instance focused on the specified frame.
Exceptions
- NoSuchFrameException
If the frame cannot be found.
Frame(string)
Select a frame by its name or ID.
IWebDriver Frame(string frameName)
Parameters
frameName
stringThe name of the frame to select.
Returns
- IWebDriver
An IWebDriver instance focused on the specified frame.
Exceptions
- NoSuchFrameException
If the frame cannot be found.
NewWindow(WindowType)
Creates a new browser window and switches the focus for future commands of this driver to the new window.
IWebDriver NewWindow(WindowType typeHint)
Parameters
typeHint
WindowTypeThe type of new browser window to be created. The created window is not guaranteed to be of the requested type; if the driver does not support the requested type, a new browser window will be created of whatever type the driver does support.
Returns
- IWebDriver
An IWebDriver instance focused on the new browser.
ParentFrame()
Select the parent frame of the currently selected frame.
IWebDriver ParentFrame()
Returns
- IWebDriver
An IWebDriver instance focused on the specified frame.
Window(string)
Switches the focus of future commands for this driver to the window with the given name.
IWebDriver Window(string windowName)
Parameters
windowName
stringThe name of the window to select.
Returns
- IWebDriver
An IWebDriver instance focused on the given window.
Exceptions
- NoSuchWindowException
If the window cannot be found.