Class WindowAction

java.lang.Object
io.fluentlenium.core.action.WindowAction

public class WindowAction extends Object
Execute actions on active window.
  • Constructor Details

    • WindowAction

      public WindowAction (FluentControl control, ComponentInstantiator instantiator, org.openqa.selenium.WebDriver driver)
      Creates a new window action.
      Parameters:
      control - control interface
      instantiator - component instantiator
      driver - selenium driver
  • Method Details

    • title

      public 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 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 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 by WebDriver.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 (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 (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