Promote Sub-request Rule
To apply a generation rule to any request, it must be a top-level request. This rule can be used to promote sub-requests in order for other generation rules to be applied to them.
This rule is useful for accessing non-HTML response content. It is also useful if you want to apply other script generation rules to non-HTML response content.
Example Script Code Changes (Java)
The following diagram illustrates how the Promote Sub-request rule works:
Url url1 = new Url(protocol1, "www.example.com", "/");
try (Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1))
{
request1.addSubRequest("http://www.example.com/res/data.json?orderID=12345&quantity=5");
try (Response response1 = request1.send())
{
....
}
}
Changes to the following:
Url url1 = new Url(protocol1, "www.example.com", "/");
try (Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1))
{
try (Response response1 = request1.send())
{
....
}
}
Url url2 = new Url(protocol1, "www.example.com/res/data.json", "connect");
QueryData queryData2 = new QueryData();
queryData2.add("orderID", "12345");
queryData2.add("quantity", "5");
url2 = url2.withQuery(queryData2);
try (Request request2 = getWebBrowser().createRequest(HttpMethod.GET, url2))
{
try (Response response2 = request2.send())
{
....
}
}
After applying this rule, a Data Correlation rule could be used to correlate the sessionID of 12345678 in the new top-level request, for example.
Generation Rules Wizard Pages
Create Request Filter
Since the purpose of this rule is to promote sub-requests, the only information required is which requests to promote. These can be described by creating a request filter on the common Create Request Filter page.
After the Create Request Filter page, the common Rule name and summary page appears.