문제

Can anyone tell me how to create an extraction rule that will allow me to pull an ID from an MVC querystring?

Scenario:

User hits site, and clicks "Add new"

Request: www.site.com/item/create
Response: www.site.com/item/view/2143

The site will instantly create a new item and redirect them to the viewitem page. The id i would like to extract lives within the response after item/view/####

Current recorded code for webtest:

var request4 = new WebTestRequest((Context["WebServerAddress"] + "/Item/Create"));
request4.Method = "POST";
var request4Body = new FormPostHttpBody();
request4.Body = request4Body;
yield return request4;
request4 = null;

//server redirect response happens now

var request5 = 
  new WebTestRequest((Context["WebServerAddress"] + "/Item/Edit/?needIdForHere"));
yield return request5;
request5 = null;

Any ideas?

Many thanks,
Kohan

도움이 되었습니까?

해결책

you may get more mileage setting the value from the WebTestContext.LastResponse.ResponseUri as an extraction rule is designed for iterating over the response body.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top