Interface BrowserActionsContract

All Known Implementing Classes:
BrowserActions, BrowserActions

public interface BrowserActionsContract
Public contract for browser-level SHAFT actions.
  • Method Details

    • and

    • assertThat

      BrowserAssertions assertThat()
    • verifyThat

      BrowserAssertions verifyThat()
    • capturePageSnapshot

      BrowserActionsContract capturePageSnapshot()
    • getCurrentURL

      String getCurrentURL()
    • getCurrentWindowTitle

      String getCurrentWindowTitle()
    • getPageSource

      String getPageSource()
    • getWindowHandle

      String getWindowHandle()
    • getWindowPosition

      String getWindowPosition()
    • getWindowSize

      String getWindowSize()
    • getWindowHeight

      String getWindowHeight()
    • getWindowWidth

      String getWindowWidth()
    • openNewTab

      default BrowserActionsContract openNewTab(String targetUrl)
      Opens the target URL in a new browser tab and switches focus to it.
      Parameters:
      targetUrl - target URL to open
      Returns:
      a self-reference to be used to chain actions
    • openNewWindow

      default BrowserActionsContract openNewWindow(String targetUrl)
      Opens the target URL in a new browser window and switches focus to it.
      Parameters:
      targetUrl - target URL to open
      Returns:
      a self-reference to be used to chain actions
    • refreshCurrentPage

      BrowserActionsContract refreshCurrentPage()
    • closeCurrentWindow

      void closeCurrentWindow()
    • maximizeWindow

      BrowserActionsContract maximizeWindow()
    • setWindowSize

      BrowserActionsContract setWindowSize(int width, int height)
    • mock

      BrowserActionsContract mock(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse)
    • interceptRequest

    • intercept

      BrowserActionsContract intercept(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse)
    • clearNetworkInterceptors

      BrowserActionsContract clearNetworkInterceptors()
    • startContractRecording

      BrowserActionsContract startContractRecording(String contractFilePath, String... urlContains)
    • assertContract

      BrowserActionsContract assertContract(String contractFilePath, String... urlContains)
    • verifyContract

      BrowserActionsContract verifyContract(String contractFilePath, String... urlContains)
    • replayContract

      BrowserActionsContract replayContract(String contractFilePath)
    • routeFromHar

      BrowserActionsContract routeFromHar(String harFilePath)
      Replays recorded HAR (HTTP Archive) responses through the browser network interceptor.
      Parameters:
      harFilePath - path to a HAR 1.2 JSON file
      Returns:
      a self-reference to be used to chain actions
    • fullScreenWindow

      BrowserActionsContract fullScreenWindow()
    • switchToWindow

      BrowserActionsContract switchToWindow(String nameOrHandle)
    • isAlertPresent

      default boolean isAlertPresent()
      Checks whether a browser alert, confirm, or prompt dialog is currently present.
      Returns:
      true when an alert is present; otherwise false
    • acceptAlert

      default BrowserActionsContract acceptAlert()
      Accepts the current browser alert, confirm, or prompt dialog.
      Returns:
      a self-reference to be used to chain actions
    • dismissAlert

      default BrowserActionsContract dismissAlert()
      Dismisses the current browser alert, confirm, or prompt dialog.
      Returns:
      a self-reference to be used to chain actions
    • getAlertText

      default String getAlertText()
      Gets the current browser alert, confirm, or prompt dialog text.
      Returns:
      the alert text
    • typeIntoPromptAlert

      default BrowserActionsContract typeIntoPromptAlert(String text)
      Types text into the current browser prompt dialog.
      Parameters:
      text - text to type into the prompt
      Returns:
      a self-reference to be used to chain actions
    • addCookie

      BrowserActionsContract addCookie(String key, String value)
    • getCookie

      org.openqa.selenium.Cookie getCookie(String cookieName)
    • getAllCookies

      Set<org.openqa.selenium.Cookie> getAllCookies()
    • getCookieDomain

      String getCookieDomain(String cookieName)
    • getCookieValue

      String getCookieValue(String cookieName)
    • getCookiePath

      String getCookiePath(String cookieName)
    • deleteCookie

      BrowserActionsContract deleteCookie(String cookieName)
    • deleteAllCookies

      BrowserActionsContract deleteAllCookies()
    • captureScreenshot

      BrowserActionsContract captureScreenshot()
    • captureScreenshot

      BrowserActionsContract captureScreenshot(Screenshots type)
    • captureSnapshot

      BrowserActionsContract captureSnapshot()
    • generateLightHouseReport

      void generateLightHouseReport()
    • waitForLazyLoading

      BrowserActionsContract waitForLazyLoading()
    • scrollToLoadAll

      default BrowserActionsContract scrollToLoadAll()
      Explicitly sweeps the current page with bounded progressive scrolling (viewport-height steps, up to timeouts.lazyLoadingScrollSweepMaxSteps), waiting for lazy-loading readiness between steps, to force scroll-triggered content (infinite lists, IntersectionObserver sections that only hydrate once visible) to fully load before full-page assertions or screenshots. Use it right before such assertions on pages known to lazy-load on scroll -- it is never invoked automatically by any readiness wait, since sweeping the whole page is not a safe default before an arbitrary action.

      Mutates scroll position during execution (restored to its original position when the sweep finishes, including on early exit).

      Returns:
      a self-reference to be used to chain actions
    • getContext

      String getContext()
    • setContext

      BrowserActionsContract setContext(String context)
    • getWindowHandles

      List<String> getWindowHandles()
    • getContextHandles

      List<String> getContextHandles()
    • accessibility

      AccessibilityActions accessibility()