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 void closeCurrentWindow()
      Closes the current browser window
    • 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
    • mock

      @Step("Mock HTTP Request") public BrowserActions mock(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse)
    • intercept

      @Step("Intercept HTTP Request") 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

      @Deprecated(forRemoval=true) public BrowserActions waitUntilTitleIs(String title)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function)

      Use this action to wait until the page title is exactly as provided

      Parameters:
      title - the expected title
      Returns:
      a self-reference for chainable actions
    • waitUntilTitleContains

      @Deprecated(forRemoval=true) public BrowserActions waitUntilTitleContains(String title)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function)

      Use this action to wait until the page title contains the provided text

      Parameters:
      title - the expected title
      Returns:
      a self-reference for chainable actions
    • waitUntilTitleNotContains

      @Deprecated(forRemoval=true) public BrowserActions waitUntilTitleNotContains(String title)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function)

      Use this action to wait until the page title does not contain the provided text

      Parameters:
      title - the expected title
      Returns:
      a self-reference for chainable actions
    • waitUntilUrlContains

      @Deprecated(forRemoval=true) public BrowserActions waitUntilUrlContains(String url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function) Use this action to wait until the current URL contains the provided text
      Parameters:
      url - the expected URL
      Returns:
      a self-reference for chainable actions
    • waitUntilUrlNotContains

      @Deprecated(forRemoval=true) public BrowserActions waitUntilUrlNotContains(String url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function) Use this action to wait until the current URL does not contain the provided text
      Parameters:
      url - the expected URL
      Returns:
      a self-reference for chainable actions
    • waitUntilUrlToBe

      @Deprecated(forRemoval=true) public BrowserActions waitUntilUrlToBe(String url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function) Use this action to wait until the current URL is exactly as provided
      Parameters:
      url - the expected URL
      Returns:
      a self-reference for chainable actions
    • waitUntilUrlNotToBe

      @Deprecated(forRemoval=true) public BrowserActions waitUntilUrlNotToBe(String url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function) Use this action to wait until the current URL is not the provided text
      Parameters:
      url - the expected URL
      Returns:
      a self-reference for chainable actions
    • waitUntilUrlMatches

      @Deprecated(forRemoval=true) public BrowserActions waitUntilUrlMatches(String urlRegex)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function) Use this action to wait until the current URL matches the provided regex
      Parameters:
      urlRegex - the expected URL regex
      Returns:
      a self-reference for chainable actions
    • waitUntilNumberOfWindowsToBe

      @Deprecated(forRemoval=true) public BrowserActions waitUntilNumberOfWindowsToBe(int expectedNumberOfWindows)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deprecated, instead you should use Actions.waitUntil(Function, Duration) or Actions.waitUntil(Function) Use this action to wait until the number of currently open windows matches the expected number
      Parameters:
      expectedNumberOfWindows - the expected number of open windows
      Returns:
      a self-reference for chainable actions
    • 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
    • accessibility

      public AccessibilityActions accessibility()
      Provides access to accessibility testing actions for the current browser session.

      This method returns an AccessibilityActions instance that can be used to perform automated accessibility checks and generate reports for the current page.

      Example usage:

      
       AccessibilityActions actions = browserActions.accessibility();
       actions.analyzePageAccessibility("HomePage");
       
      Returns:
      an AccessibilityActions object tied to the current browser session