Package org.fluentlenium.core.switchto
Interface FluentTargetLocator<T>
-
- Type Parameters:
T
- self type
- All Known Implementing Classes:
FluentTargetLocatorImpl
public interface FluentTargetLocator<T>
Used to locate a given frame or window.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FluentWebElement
activeElement()
Switches to the element that currently has focus within the document currently "switched to", or the body element if this cannot be detected.AlertImpl
alert()
Switches to the currently active modal dialog for this particular driver instance.T
defaultContent()
Selects either the first frame on the page, or the main document when a page contains iframes.T
frame(int index)
Select a frame by its (zero-based) index.T
frame(java.lang.String nameOrId)
Select a frame by its name or ID.T
frame(FluentWebElement frameElement)
Select a frame using its previously locatedWebElement
.T
frame(org.openqa.selenium.WebElement frameElement)
Select a frame using its previously locatedWebElement
.T
parentFrame()
Change focus to the parent context.T
window(java.lang.String nameOrHandle)
Switch the focus of future commands for this driver to the window with the given name/handle.
-
-
-
Method Detail
-
frame
T 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.- Parameters:
index
- (zero-based) index- Returns:
- $
this
reference for chain calls. - Throws:
org.openqa.selenium.NoSuchFrameException
- If the frame cannot be found
-
frame
T 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:
org.openqa.selenium.NoSuchFrameException
- If the frame cannot be found
-
frame
T frame(org.openqa.selenium.WebElement frameElement)
Select a frame using its previously locatedWebElement
.- Parameters:
frameElement
- The frame element to switch to.- Returns:
- This driver focused on the given frame.
- Throws:
org.openqa.selenium.NoSuchFrameException
- If the given element is neither an IFRAME nor a FRAME element.org.openqa.selenium.StaleElementReferenceException
- If the WebElement has gone stale.
-
frame
T frame(FluentWebElement frameElement)
Select a frame using its previously locatedWebElement
.- Parameters:
frameElement
- The frame element to switch to.- Returns:
- This driver focused on the given frame.
- Throws:
org.openqa.selenium.NoSuchFrameException
- If the given element is neither an IFRAME nor a FRAME element.org.openqa.selenium.StaleElementReferenceException
- If the WebElement has gone stale.
-
parentFrame
T parentFrame()
Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.- Returns:
- This driver focused on the parent frame
-
window
T window(java.lang.String nameOrHandle)
Switch the focus of future commands for this driver to the window with the given name/handle.- Parameters:
nameOrHandle
- The name of the window or the handle as returned byWebDriver.getWindowHandle()
- Returns:
- This driver focused on the given window
- Throws:
org.openqa.selenium.NoSuchWindowException
- If the window cannot be found
-
defaultContent
T defaultContent()
Selects either the first frame on the page, or the main document when a page contains iframes.- Returns:
- This driver focused on the top window/first frame.
-
activeElement
FluentWebElement 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.- Returns:
- The WebElement with focus, or the body element if no element with focus can be detected.
-
alert
AlertImpl alert()
Switches to the currently active modal dialog for this particular driver instance.- Returns:
- A handle to the dialog.
- Throws:
org.openqa.selenium.NoAlertPresentException
- If the dialog cannot be found
-
-