Class NetworkRequests
java.lang.Object
net.serenitybdd.screenplay.playwright.questions.NetworkRequests
Query captured network requests.
Before using these questions, you must start capturing network requests
using CaptureNetworkRequests.duringTest().
Sample usage:
// Start capturing
actor.attemptsTo(CaptureNetworkRequests.duringTest());
// ... perform actions ...
// Query requests
List<CapturedRequest> all = actor.asksFor(NetworkRequests.all());
List<CapturedRequest> failed = actor.asksFor(NetworkRequests.failed());
List<CapturedRequest> apiCalls = actor.asksFor(NetworkRequests.toUrlContaining("/api/"));
// Get counts
int failedCount = actor.asksFor(NetworkRequests.failedCount());
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>>all()Get all captured network requests.static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>>Get all requests with client errors (4xx status codes).static net.serenitybdd.screenplay.Question<Integer>count()Get the count of all captured requests.static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>>failed()Get all failed requests (network errors or 4xx/5xx status codes).static net.serenitybdd.screenplay.Question<Integer>Get the count of failed requests.static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>>Get requests to URLs matching the specified glob pattern.static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>>Get all requests with server errors (5xx status codes).static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>>toUrlContaining(String urlSubstring) Get requests to URLs containing the specified substring.static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>>withMethod(String method) Get requests with the specified HTTP method.
-
Method Details
-
all
public static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>> all()Get all captured network requests. -
failed
public static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>> failed()Get all failed requests (network errors or 4xx/5xx status codes). -
clientErrors
public static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>> clientErrors()Get all requests with client errors (4xx status codes). -
serverErrors
public static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>> serverErrors()Get all requests with server errors (5xx status codes). -
toUrlContaining
public static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>> toUrlContaining(String urlSubstring) Get requests to URLs containing the specified substring.- Parameters:
urlSubstring- The substring to match in URLs
-
matching
public static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>> matching(String pattern) Get requests to URLs matching the specified glob pattern. Supports * (any characters) and ** (any path segment).- Parameters:
pattern- The glob pattern (e.g., "**\/api/**")
-
withMethod
public static net.serenitybdd.screenplay.Question<List<CaptureNetworkRequests.CapturedRequest>> withMethod(String method) Get requests with the specified HTTP method.- Parameters:
method- The HTTP method (GET, POST, etc.)
-
count
Get the count of all captured requests. -
failedCount
Get the count of failed requests.
-