Class NetworkInterceptionRequestBuilder
java.lang.Object
com.shaft.gui.browser.NetworkInterceptionRequestBuilder
Fluent builder for browser network request interception.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFluent mocked response builder. -
Method Summary
Modifier and TypeMethodDescriptionassertResponse(Consumer<RestValidationsBuilder> validation) Validates matched real responses with SHAFT hard assertions.bodyContains(String text) Matches requests whose body contains the given text.delete()get()Matches requests that include the expected header value.Adds a custom request predicate.method(org.openqa.selenium.remote.http.HttpMethod method) Matches requests with the supplied HTTP method.patch()pathContains(String text) Matches requests whose URL path contains the given text.pathEquals(String path) Matches requests whose URL path equals the given value.post()put()queryParam(String name, String value) Matches requests that include the expected query parameter value.respond()Starts building a mocked response for matched requests.urlContains(String text) Matches requests whose full URL contains the given text.urlMatches(String regex) Matches requests whose full URL matches the given regular expression.verifyResponse(Consumer<RestValidationsBuilder> validation) Validates matched real responses with SHAFT soft verifications.
-
Method Details
-
method
Matches requests with the supplied HTTP method.- Parameters:
method- HTTP method to match- Returns:
- this builder
-
get
- Returns:
- this builder configured to match GET requests
-
post
- Returns:
- this builder configured to match POST requests
-
put
- Returns:
- this builder configured to match PUT requests
-
patch
- Returns:
- this builder configured to match PATCH requests
-
delete
- Returns:
- this builder configured to match DELETE requests
-
urlContains
Matches requests whose full URL contains the given text.- Parameters:
text- URL fragment- Returns:
- this builder
-
urlMatches
Matches requests whose full URL matches the given regular expression.- Parameters:
regex- URL regular expression- Returns:
- this builder
-
pathEquals
Matches requests whose URL path equals the given value.- Parameters:
path- expected URL path- Returns:
- this builder
-
pathContains
Matches requests whose URL path contains the given text.- Parameters:
text- path fragment- Returns:
- this builder
-
queryParam
Matches requests that include the expected query parameter value.- Parameters:
name- query parameter namevalue- expected value- Returns:
- this builder
-
header
Matches requests that include the expected header value.- Parameters:
name- header namevalue- expected value- Returns:
- this builder
-
bodyContains
Matches requests whose body contains the given text.- Parameters:
text- body fragment- Returns:
- this builder
-
matching
public NetworkInterceptionRequestBuilder matching(Predicate<org.openqa.selenium.remote.http.HttpRequest> predicate) Adds a custom request predicate.- Parameters:
predicate- predicate to apply- Returns:
- this builder
-
respond
Starts building a mocked response for matched requests.- Returns:
- mocked response builder
-
assertResponse
Validates matched real responses with SHAFT hard assertions.- Parameters:
validation- response validation callback- Returns:
- the owning browser actions object
-
verifyResponse
Validates matched real responses with SHAFT soft verifications.- Parameters:
validation- response validation callback- Returns:
- the owning browser actions object
-