Package org.openqa.selenium
Interface WebDriver.TargetLocator
- 
- Enclosing interface:
- WebDriver
 
 public static interface WebDriver.TargetLocatorUsed to locate a given frame or window.
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description WebElementactiveElement()Switches to the element that currently has focus within the document currently "switched to", or the body element if this cannot be detected.Alertalert()Switches to the currently active modal dialog for this particular driver instance.WebDriverdefaultContent()Selects either the first frame on the page, or the main document when a page contains iframes.WebDriverframe(int index)Select a frame by its (zero-based) index.WebDriverframe(java.lang.String nameOrId)Select a frame by its name or ID.WebDriverframe(WebElement frameElement)Select a frame using its previously locatedWebElement.WebDrivernewWindow(WindowType typeHint)Creates a new browser window and switches the focus for future commands of this driver to the new window.WebDriverparentFrame()Change focus to the parent context.WebDriverwindow(java.lang.String nameOrHandle)Switch the focus of future commands for this driver to the window with the given name/handle.
 
- 
- 
- 
Method Detail- 
frameWebDriver frame(int index) Select a frame by its (zero-based) index. Selecting a frame by index is equivalent to the JS expression window.frames[index] where "window" is the DOM window represented by the current context. Once the frame has been selected, all subsequent calls on the WebDriver interface are made to that frame.See W3C WebDriver specification for more details. - Parameters:
- index- (zero-based) index
- Returns:
- This driver focused on the given frame
- Throws:
- NoSuchFrameException- If the frame cannot be found
 
 - 
frameWebDriver frame(java.lang.String nameOrId) Select a frame by its name or ID. Frames located by matching name attributes are always given precedence over those matched by ID.- Parameters:
- nameOrId- the name of the frame window, the id of the <frame> or <iframe> element, or the (zero-based) index
- Returns:
- This driver focused on the given frame
- Throws:
- NoSuchFrameException- If the frame cannot be found
 
 - 
frameWebDriver frame(WebElement frameElement) Select a frame using its previously locatedWebElement.See W3C WebDriver specification for more details. - Parameters:
- frameElement- The frame element to switch to.
- Returns:
- This driver focused on the given frame.
- Throws:
- NoSuchFrameException- If the given element is neither an IFRAME nor a FRAME element.
- StaleElementReferenceException- If the WebElement has gone stale.
- See Also:
- WebDriver.findElement(By)
 
 - 
parentFrameWebDriver parentFrame() Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.See W3C WebDriver specification for more details. - Returns:
- This driver focused on the parent frame
 
 - 
windowWebDriver window(java.lang.String nameOrHandle) Switch the focus of future commands for this driver to the window with the given name/handle.See W3C WebDriver specification for more details. - Parameters:
- nameOrHandle- The name of the window or the handle as returned by- WebDriver.getWindowHandle()
- Returns:
- This driver focused on the given window
- Throws:
- NoSuchWindowException- If the window cannot be found
 
 - 
newWindowWebDriver newWindow(WindowType typeHint) Creates a new browser window and switches the focus for future commands of this driver to the new window.See W3C WebDriver specification for more details. - Parameters:
- typeHint- The 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:
- This driver focused on the given window
 
 - 
defaultContentWebDriver defaultContent() Selects either the first frame on the page, or the main document when a page contains iframes.See W3C WebDriver specification for more details. - Returns:
- This driver focused on the top window/first frame.
 
 - 
activeElementWebElement activeElement() Switches to the element that currently has focus within the document currently "switched to", or the body element if this cannot be detected. This matches the semantics of calling "document.activeElement" in Javascript.See W3C WebDriver specification for more details. - Returns:
- The WebElement with focus, or the body element if no element with focus can be detected.
 
 - 
alertAlert alert() Switches to the currently active modal dialog for this particular driver instance.- Returns:
- A handle to the dialog.
- Throws:
- NoAlertPresentException- If the dialog cannot be found
 
 
- 
 
-