Class BrowserNetworkInterceptor
java.lang.Object
com.shaft.gui.browser.internal.BrowserNetworkInterceptor
- All Implemented Interfaces:
AutoCloseable
Owns browser network interception rules for one WebDriver session.
-
Constructor Summary
ConstructorsConstructorDescriptionBrowserNetworkInterceptor(org.openqa.selenium.WebDriver driver) Creates a browser network interceptor backed by Selenium DevTools. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a rule and activates it for the current browser session.voidclear()Clears all registered rules.voidclose()Clears rules and removes the Selenium network filter during driver teardown.booleanReports whether this interceptor has one or more mock/validate rules registered.booleanReleases this interceptor's DevTools network filter so another owner (for example a dedicated API-capture recorder that composes the same trace/HAR observation inside its own filter) can become the sole registrant for this driver.booleanStarts passive network observation without changing existing mock/assert/verify rules.
-
Constructor Details
-
BrowserNetworkInterceptor
public BrowserNetworkInterceptor(org.openqa.selenium.WebDriver driver) Creates a browser network interceptor backed by Selenium DevTools.- Parameters:
driver- the active WebDriver session
-
-
Method Details
-
addRule
Adds a rule and activates it for the current browser session.- Parameters:
rule- rule to add
-
startObserving
public boolean startObserving()Starts passive network observation without changing existing mock/assert/verify rules.- Returns:
truewhen observation started
-
hasActiveRules
public boolean hasActiveRules()Reports whether this interceptor has one or more mock/validate rules registered.Callers that want to take over sole ownership of the DevTools network filter (for example a dedicated API-capture recorder) must not do so while rules are registered here: replacing this interceptor's filter would silently drop active mocking/validation behavior with no warning to the caller that registered those rules.
- Returns:
truewhen at least one interception rule is registered
-
releaseForHandoff
public boolean releaseForHandoff()Releases this interceptor's DevTools network filter so another owner (for example a dedicated API-capture recorder that composes the same trace/HAR observation inside its own filter) can become the sole registrant for this driver.Only safe to call when
hasActiveRules()isfalse: this method does not clear registered rules, and calling it while rules exist would leave them registered here but inactive on the driver, silently breaking any mock/validate behavior callers still expect.- Returns:
truewhen passive observation was active and has been released
-
clear
public void clear()Clears all registered rules. Passive trace observation remains active when it was started for the session. -
close
public void close()Clears rules and removes the Selenium network filter during driver teardown.- Specified by:
closein interfaceAutoCloseable
-