Package org.fluentlenium.core.action
Class WindowAction
- java.lang.Object
-
- org.fluentlenium.core.action.WindowAction
-
public class WindowAction extends java.lang.Object
Execute actions on active window.
-
-
Constructor Summary
Constructors Constructor Description WindowAction(FluentControl control, ComponentInstantiator instantiator, org.openqa.selenium.WebDriver driver)
Creates a new window action.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clickAndCloseCurrent(FluentWebElement button)
Clicks button, which closes current window and switches to last window (in set returned byWebDriver.getWindowHandles()
).java.lang.String
clickAndOpenNew(FluentWebElement button)
Clicks button, which opens new window and switches to newly opened window.void
close()
Close the current window.WindowAction
fullscreen()
FullScreen the current window.org.openqa.selenium.Point
getPosition()
Gets the current window position.org.openqa.selenium.Dimension
getSize()
Gets the current window size.org.openqa.selenium.WebDriver.Window
getWindow()
Gets the current window object.WindowAction
maximize()
Maximize the current window.java.lang.String
openNewAndSwitch()
Opens new window.WindowAction
setPosition(org.openqa.selenium.Point position)
Sets the current window position.WindowAction
setSize(org.openqa.selenium.Dimension size)
Sets the current window size.FluentTargetLocator<WindowAction>
switchTo()
Create a switch target locator.WindowAction
switchTo(java.lang.String nameOrHandle)
Switches to particular window by handle.WindowAction
switchToLast()
Switches to lastly opened window.WindowAction
switchToLast(java.lang.String nameOrHandleToExclude)
Switches to lastly opened window excluding the one provided as a parameter.java.lang.String
title()
Gets the page title.
-
-
-
Constructor Detail
-
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 Detail
-
title
public java.lang.String title()
Gets the page title.- Returns:
- page title text
-
maximize
public WindowAction maximize()
Maximize the current window.- Returns:
- the WindowAction object itself
-
fullscreen
public WindowAction fullscreen()
FullScreen the current window.- Returns:
- the WindowAction object itself
-
setSize
public WindowAction setSize(org.openqa.selenium.Dimension size)
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
public WindowAction setPosition(org.openqa.selenium.Point position)
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
public java.lang.String clickAndOpenNew(FluentWebElement button)
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
public java.lang.String openNewAndSwitch()
Opens new window.- Returns:
- handle of old (parent) window
-
clickAndCloseCurrent
public void clickAndCloseCurrent(FluentWebElement button)
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
public FluentTargetLocator<WindowAction> switchTo()
Create a switch target locator.- Returns:
- an object to perform switch on various target.
-
switchToLast
public WindowAction switchToLast()
Switches to lastly opened window.- Returns:
- the WindowAction object itself
-
switchToLast
public WindowAction switchToLast(java.lang.String nameOrHandleToExclude)
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
public WindowAction switchTo(java.lang.String nameOrHandle)
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
-
-