Package io.fluentlenium.core.action
Class WindowAction
java.lang.Object
io.fluentlenium.core.action.WindowAction
Execute actions on active window.
-
Constructor Summary
ConstructorsConstructorDescriptionWindowAction
(FluentControl control, ComponentInstantiator instantiator, org.openqa.selenium.WebDriver driver) Creates a new window action. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clickAndCloseCurrent
(FluentWebElement button) Clicks button, which closes current window and switches to last window (in set returned byWebDriver.getWindowHandles()
).clickAndOpenNew
(FluentWebElement button) Clicks button, which opens new window and switches to newly opened window.void
close()
Close the current window.FullScreen the current window.org.openqa.selenium.Point
Gets the current window position.org.openqa.selenium.Dimension
getSize()
Gets the current window size.org.openqa.selenium.WebDriver.Window
Gets the current window object.maximize()
Maximize the current window.Opens new window.setPosition
(org.openqa.selenium.Point position) Sets the current window position.setSize
(org.openqa.selenium.Dimension size) Sets the current window size.switchTo()
Create a switch target locator.Switches to particular window by handle.Switches to lastly opened window.switchToLast
(String nameOrHandleToExclude) Switches to lastly opened window excluding the one provided as a parameter.title()
Gets the page title.
-
Constructor Details
-
WindowAction
public WindowAction(FluentControl control, ComponentInstantiator instantiator, org.openqa.selenium.WebDriver driver) Creates a new window action.- Parameters:
control
- control interfaceinstantiator
- component instantiatordriver
- selenium driver
-
-
Method Details
-
title
Gets the page title.- Returns:
- page title text
-
maximize
Maximize the current window.- Returns:
- the WindowAction object itself
-
fullscreen
FullScreen the current window.- Returns:
- the WindowAction object itself
-
setSize
Sets the current window size.- Parameters:
size
- size of the window- Returns:
- the WindowAction object itself
-
getSize
public org.openqa.selenium.Dimension getSize()Gets the current window size.- Returns:
- the current window size
-
setPosition
Sets the current window position.- Parameters:
position
- position to set- Returns:
- the WindowAction object itself
-
getPosition
public org.openqa.selenium.Point getPosition()Gets the current window position.- Returns:
- the WindowAction object itself
-
clickAndOpenNew
Clicks button, which opens new window and switches to newly opened window.This method doesn't force opening window in new window, we assume the code under test will open new window.
- Parameters:
button
- button to be clicked- Returns:
- handle of old (parent) window
-
openNewAndSwitch
Opens new window.- Returns:
- handle of old (parent) window
-
clickAndCloseCurrent
Clicks button, which closes current window and switches to last window (in set returned byWebDriver.getWindowHandles()
).If the last window is not the target window, use
switchTo(String)
to focus on desired window- Parameters:
button
- button to be clicked
-
close
public void close()Close the current window. -
switchTo
Create a switch target locator.- Returns:
- an object to perform switch on various target.
-
switchToLast
Switches to lastly opened window.- Returns:
- the WindowAction object itself
-
switchToLast
Switches to lastly opened window excluding the one provided as a parameter.- Parameters:
nameOrHandleToExclude
- if list size is greater than one it will be removed- Returns:
- the WindowAction object itself
-
switchTo
Switches to particular window by handle.- Parameters:
nameOrHandle
- window name or handle- Returns:
- the WindowAction object itself
-
getWindow
public org.openqa.selenium.WebDriver.Window getWindow()Gets the current window object.- Returns:
- the WebDriver.Window object
-