Class BrowserActions


public class BrowserActions extends FluentWebDriverAction
  • Constructor Details

    • BrowserActions

      public BrowserActions()
    • BrowserActions

      public BrowserActions(org.openqa.selenium.WebDriver driver)
    • BrowserActions

      public BrowserActions(org.openqa.selenium.WebDriver driver, boolean isSilent)
    • BrowserActions

      public BrowserActions(DriverFactoryHelper helper)
  • Method Details

    • and

      public BrowserActions and()
      Overrides:
      and in class FluentWebDriverAction
    • assertThat

    • verifyThat

    • capturePageSnapshot

      public BrowserActions capturePageSnapshot()
      Attempts to capture a page snapshot archive in the format of a .mht file Works only for Chromium based driver instances For other driver types attempts to attach the current page source (for web) or accessibility tree (for mobile)
      Returns:
      a self-reference to be used to chain actions
    • getCurrentURL

      public String getCurrentURL()
      Gets the current page URL and returns it as a string
      Returns:
      the URL that's currently open in the current page
    • getCurrentWindowTitle

      public String getCurrentWindowTitle()
      Gets the current window title and returns it as a string
      Returns:
      the title of the current window
    • getPageSource

      public String getPageSource()
      Gets the current page source and returns it as a string
      Returns:
      the source of the current page
    • getWindowHandle

      public String getWindowHandle()
      Gets the current window handle and returns it as a string
      Returns:
      the window handle for the current window
    • getWindowPosition

      public String getWindowPosition()
      Gets the current window position and returns it as a string
      Returns:
      the position of the current window
    • getWindowSize

      public String getWindowSize()
      Gets the current window size and returns it as a string
      Returns:
      the size of the current window
    • getWindowHeight

      public String getWindowHeight()
      Gets the current window size and returns it as a string
      Returns:
      the height of the current window
    • getWindowWidth

      public String getWindowWidth()
      Gets the current window size and returns it as a string
      Returns:
      the width of the current window
    • refreshCurrentPage

      public BrowserActions refreshCurrentPage()
      Attempts to refresh the current page
      Returns:
      a self-reference to be used to chain actions
    • closeCurrentWindow

      public BrowserActions closeCurrentWindow()
      Closes the current browser window
      Returns:
      a self-reference to be used to chain actions
    • maximizeWindow

      public BrowserActions maximizeWindow()
      Maximizes current window size based on screen size minus 5%
      Returns:
      a self-reference to be used to chain actions
    • setWindowSize

      public BrowserActions setWindowSize(int width, int height)
      Resizes the current window size based on the provided width and height
      Parameters:
      width - the desired new width of the target window
      height - the desired new height of the target window
      Returns:
      a self-reference to be used to chain actions
    • getLocalStorage

      public org.openqa.selenium.html5.LocalStorage getLocalStorage()
    • getSessionStorage

      public org.openqa.selenium.html5.SessionStorage getSessionStorage()
    • mock

      public BrowserActions mock(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse)
    • intercept

      public BrowserActions intercept(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse)
    • fullScreenWindow

      public BrowserActions fullScreenWindow()
      Resize the window to fill the current screen
      Returns:
      a self-reference to be used to chain actions
    • switchToWindow

      public BrowserActions switchToWindow(String nameOrHandle)
      Switches focus to another window
      Parameters:
      nameOrHandle - The name of the window or the handle as returned by ElementActions.getWindowHandle(WebDriver driver)
      Returns:
      a self-reference to be used to chain actions
    • addCookie

      public BrowserActions addCookie(String key, String value)
      Adds a cookie to the current browsing context.
      Parameters:
      key - The cookie's name
      value - The cookie's name
      Returns:
      a self-reference to be used to chain actions
    • getCookie

      public org.openqa.selenium.Cookie getCookie(String cookieName)
      Gets a cookie with a given name.
      Parameters:
      cookieName - The cookie's name.
      Returns:
      the cookie.
    • getAllCookies

      public Set<org.openqa.selenium.Cookie> getAllCookies()
      Gets all cookies for the current browsing context.
      Returns:
      A Set of cookies for the current browsing context.
    • getCookieDomain

      public String getCookieDomain(String cookieName)
      Gets the cookie domain.
      Parameters:
      cookieName - The cookie's name.
      Returns:
      te cookie domain;
    • getCookieValue

      public String getCookieValue(String cookieName)
      Gets the cookie value.
      Parameters:
      cookieName - The cookie's name.
      Returns:
      the cookie value;
    • getCookiePath

      public String getCookiePath(String cookieName)
      Gets the cookie path.
      Parameters:
      cookieName - The cookie's name.
      Returns:
      the cookie path;
    • deleteCookie

      public BrowserActions deleteCookie(String cookieName)
      Deletes the cookie data matching with the provided cookie name for the current browsing context.
      Parameters:
      cookieName - The name of the cookie to delete.
      Returns:
      a self-reference to be used to chain actions.
    • deleteAllCookies

      public BrowserActions deleteAllCookies()
      Deletes all the cookies of the current browsing context.
      Returns:
      a self-reference to be used to chain actions.
    • captureScreenshot

      public BrowserActions captureScreenshot()
      Use this action to return a full page screenshot. This is a synonym to captureScreenshot(Screenshots type) if you pass `Screenshots.FULL`
      Returns:
      a self-reference for chainable actions
    • captureScreenshot

      public BrowserActions captureScreenshot(Screenshots type)
      Use this action to return a page screenshot. If you want to capture a screenshot then use this method instead
      Parameters:
      type - can either be `Screenshots.FULL`, or `Screenshots.VIEWPORT`
      Returns:
      a self-reference for chainable actions
    • captureSnapshot

      public BrowserActions captureSnapshot()
      Use this action to return a page snapshot. A page snapshot is a single .mht file that contains the full page DOM and any related assets to help you view the page as a whole. If you want to capture a screenshot then use this method instead @see FluentBrowserActions#captureScreenshot()
      Returns:
      a self-reference for chainable actions
    • generateLightHouseReport

      public void generateLightHouseReport()
    • waitForLazyLoading

      public BrowserActions waitForLazyLoading()
    • waitUntilTitleIs

      public BrowserActions waitUntilTitleIs(String title)
    • waitUntilTitleContains

      public BrowserActions waitUntilTitleContains(String title)
    • waitUntilTitleNotContains

      public BrowserActions waitUntilTitleNotContains(String title)
    • waitUntilUrlContains

      public BrowserActions waitUntilUrlContains(String url)
    • waitUntilUrlNotContains

      public BrowserActions waitUntilUrlNotContains(String url)
    • waitUntilUrlToBe

      public BrowserActions waitUntilUrlToBe(String url)
    • waitUntilUrlNotToBe

      public BrowserActions waitUntilUrlNotToBe(String url)
    • waitUntilUrlMatches

      public BrowserActions waitUntilUrlMatches(String urlRegex)
    • waitUntilNumberOfWindowsToBe

      public BrowserActions waitUntilNumberOfWindowsToBe(int numberOfWindows)
    • getContext

      public String getContext()
      Returns the handle for currently active context. This can be used to switch to this context at a later time.
      Returns:
      The current context handle
    • setContext

      public BrowserActions setContext(String context)
      Switches focus to another context
      Parameters:
      context - The name of the context or the handle as returned by ElementActions.getContext(WebDriver driver)
      Returns:
      a self-reference to be used to chain actions
    • getWindowHandles

      public List<String> getWindowHandles()
      Returns a list of unique handles for all the currently open windows. This can be used to switch to any of these windows at a later time.
      Returns:
      list of window handles
    • getContextHandles

      public List<String> getContextHandles()
      Returns a list of unique handles for all the currently open contexts. This can be used to switch to any of these contexts at a later time.
      Returns:
      list of context handles