Interface BrowserActionsContract
- All Known Implementing Classes:
BrowserActions, BrowserActions
public interface BrowserActionsContract
Public contract for browser-level SHAFT actions.
-
Method Summary
Modifier and TypeMethodDescriptiondefault BrowserActionsContractAccepts the current browser alert, confirm, or prompt dialog.and()assertContract(String contractFilePath, String... urlContains) captureScreenshot(Screenshots type) voiddeleteCookie(String cookieName) default BrowserActionsContractDismisses the current browser alert, confirm, or prompt dialog.voiddefault StringGets the current browser alert, confirm, or prompt dialog text.Set<org.openqa.selenium.Cookie> org.openqa.selenium.CookiegetCookieDomain(String cookieName) getCookiePath(String cookieName) getCookieValue(String cookieName) intercept(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse) default booleanChecks whether a browser alert, confirm, or prompt dialog is currently present.mock(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse) navigateToURL(String targetUrl) navigateToURL(String targetUrl, String targetUrlAfterRedirection) navigateToURL(String targetUrl, org.openqa.selenium.WindowType windowType) navigateToURLWithBasicAuthentication(String targetUrl, String username, String password, String targetUrlAfterAuthentication) default BrowserActionsContractopenNewTab(String targetUrl) Opens the target URL in a new browser tab and switches focus to it.default BrowserActionsContractopenNewWindow(String targetUrl) Opens the target URL in a new browser window and switches focus to it.replayContract(String contractFilePath) routeFromHar(String harFilePath) Replays recorded HAR (HTTP Archive) responses through the browser network interceptor.default BrowserActionsContractExplicitly sweeps the current page with bounded progressive scrolling (viewport-height steps, up totimeouts.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.setContext(String context) setWindowSize(int width, int height) startContractRecording(String contractFilePath, String... urlContains) switchToWindow(String nameOrHandle) default BrowserActionsContracttypeIntoPromptAlert(String text) Types text into the current browser prompt dialog.verifyContract(String contractFilePath, String... urlContains)
-
Method Details
-
and
BrowserActionsContract 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
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
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
-
mock
BrowserActionsContract mock(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse) -
interceptRequest
NetworkInterceptionRequestBuilder interceptRequest() -
intercept
BrowserActionsContract intercept(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse) -
clearNetworkInterceptors
BrowserActionsContract clearNetworkInterceptors() -
startContractRecording
-
assertContract
-
verifyContract
-
replayContract
-
routeFromHar
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
-
isAlertPresent
default boolean isAlertPresent()Checks whether a browser alert, confirm, or prompt dialog is currently present.- Returns:
truewhen an alert is present; otherwisefalse
-
acceptAlert
Accepts the current browser alert, confirm, or prompt dialog.- Returns:
- a self-reference to be used to chain actions
-
dismissAlert
Dismisses the current browser alert, confirm, or prompt dialog.- Returns:
- a self-reference to be used to chain actions
-
getAlertText
Gets the current browser alert, confirm, or prompt dialog text.- Returns:
- the alert text
-
typeIntoPromptAlert
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
-
getCookie
-
getAllCookies
Set<org.openqa.selenium.Cookie> getAllCookies() -
getCookieDomain
-
getCookieValue
-
getCookiePath
-
deleteCookie
-
deleteAllCookies
BrowserActionsContract deleteAllCookies() -
captureScreenshot
BrowserActionsContract captureScreenshot() -
captureScreenshot
-
captureSnapshot
BrowserActionsContract captureSnapshot() -
generateLightHouseReport
void generateLightHouseReport() -
waitForLazyLoading
BrowserActionsContract waitForLazyLoading() -
scrollToLoadAll
Explicitly sweeps the current page with bounded progressive scrolling (viewport-height steps, up totimeouts.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
-
getWindowHandles
-
getContextHandles
-
accessibility
AccessibilityActions accessibility()
-