RESTClient

Workflows, Loops, and Results

WithWorkflow wraps a sequence of REST calls into a named, reusable block. While loops the workflow as long as a condition is true. Until loops until a condition becomes true. WithResultName assigns a name to the next Execute result so subsequent calls can reference it with FromResult methods instead of storing it in a variable. GetExecutionResults retrieves all named and unnamed results from the current workflow as a ResultCollection. ClearResults empties the collected results and ClearWorkflows the queued workflows. SaveResultsTo writes the results to a file. The FromResult setters feed one call from an earlier call's result by index: WithXPathFromResult, WithCssFromResult, WithElementFromResult, WithKeyFromResult, WithPixelsFromResult, WithHPixelsFromResult, WithVPixelsFromResult, WithTabIdFromResult, WithWindowIdFromResult and WithReferrerFromResult.

Examples

GPAL Fluent: High-level fluent C# API

//WithResultName followed by AndThen() stores the result and returns the same client for continued chaining. The named result is then available via any WithXxxFromResult method in subsequent calls.

// the client object first, then the calls on it

IRESTClient client = (IRESTClient)GPAL.RESTClient

.WithAPIBase("http://localhost:9222")

.ToGPALObject();


// Loop until the page reaches a certain state

client

.WithWorkflow(c => c

.GoTo((GPALUrl)GPAL.Url.ForUrl("https://example.com/job/123").ToGPALObject())

.Execute())

.Until(() =>

{

string status = client

.QuerySelector(".status-badge")

.Execute();


return status.Contains("Complete");

});


// Name a result for use downstream

client.WithResultName("orderId");


client

.QuerySelector("#order-id")

.AndThen()

.WithEndpoint(ApiEndpoint.GoTo)

.WithUrlFromResult("orderId")

.Execute();

💬 Ask GPAL