우리는 세션 ID를 표시하는 URL로 리디렉션하는 ASP.Net 사이트가 있습니다. 같은 :URL에 세션 ID가있는 Webtest
이 ID는 모든 요청에 고유합니다.
표준 시각 스튜디오 2008/2010 webtest를 사용하여이 사이트를 테스트 할 수 있습니까? 어떻게이 데이터를 테스트 할 수 있습니까?
동일한 ID를 사용하여 여러 페이지를 호출해야합니다.
우리는 세션 ID를 표시하는 URL로 리디렉션하는 ASP.Net 사이트가 있습니다. 같은 :URL에 세션 ID가있는 Webtest
이 ID는 모든 요청에 고유합니다.
표준 시각 스튜디오 2008/2010 webtest를 사용하여이 사이트를 테스트 할 수 있습니까? 어떻게이 데이터를 테스트 할 수 있습니까?
동일한 ID를 사용하여 여러 페이지를 호출해야합니다.
예, 비교적 쉽게 처리 할 수 있습니다. 그러나 코드화 된 웹 테스트를 만들어야합니다.
예에서 우리는 세션 문자열을 포함하는 URL을 반환하는 로그인 게시물을 가지고 있습니다. 로그인 게시물 요청 (request3)을 열거 자에게 양보 한 직후에 다음을 호출합니다. 당신이 세션 쿠키 문자열이 있으면
public static string GetUrlCookie(string fullUrl, string webServerUrl, string afterUrlPArt)
{
string result = fullUrl.Substring(webServerUrl.Length);
result = result.Substring(0, result.Length - afterUrlPArt.Length);
return result;
}
, 당신은 예를 게시/요청에 대한 후속 URL을에 정말 쉽게 대체 할 수 있습니다 : GetUrlCookie이 같은 것입니다
WebTestRequest request3 = new WebTestRequest((this.Context["WebServer1"].ToString() + "/ICS/Login/English/Login.aspx"));
//more request setup code removed for clarity
yield return request3;
string responseUrl = Context.LastResponse.ResponseUri.AbsoluteUri;
string cookieUrl = GetUrlCookie(responseUrl, this.Context["WebServer1"].ToString(),"/main.aspx");
request3 = null;
WebTestRequest request4 = new WebTestRequest((this.Context["WebServer1"].ToString() + cookieUrl + "/mySecureForm.aspx"));
내 코드가 너무 거친 것에 대해 사과하지만 내 프로젝트에서 사용되지 않습니다 및 코드베이스의 첫 번째 버전에서 가져온 - 그리고이 모든 부하 테스트에 대한
: 쉬웠다 말에 대한 응용 프로그램에 따라 테스트를 실행할 때마다 별도의 로그인 정보를 제공하기 위해 호출하는 저장 프로 시저를 만들어야 할 수도 있습니다.
응답 URL을 미리 결정할 수 없으므로 로그인 게시물에 대해 urlValidationEventHandler를 일시적으로 꺼야합니다. 내가 필요로
이 ValidateResponseUrl validationRule1 = new ValidateResponseUrl();
urlValidationRuleEventHandler = new EventHandler<ValidationEventArgs>(validationRule1.Validate);
그래서 다음에 그것을 켤 수 있습니다 오프 :
this.ValidateResponse -= urlValidationRuleEventHandler ;
this.ValidateResponse += urlValidationRuleEventHandler ;
대안은 자신이 이와 같은 (reflectored을 코딩하는 것입니다 내가 로컬 변수에 validationruleeventhandler 저장이 작업을 수행하려면 Visual Studio 코드에서 변경하고 대소 문자를 구분하지 않도록 변경했습니다.
class QueryLessCaseInsensitiveValidateResponseUrl : ValidateResponseUrl
{
public override void Validate(object sender, ValidationEventArgs e)
{
Uri uri;
string uriString = string.IsNullOrEmpty(e.Request.ExpectedResponseUrl) ? e.Request.Url : e.Request.ExpectedResponseUrl;
if (!Uri.TryCreate(e.Request.Url, UriKind.Absolute, out uri))
{
e.Message = "The request URL could not be parsed";
e.IsValid = false;
}
else
{
Uri uri2;
string leftPart = uri.GetLeftPart(UriPartial.Path);
if (!Uri.TryCreate(uriString, UriKind.Absolute, out uri2))
{
e.Message = "The request URL could not be parsed";
e.IsValid = false;
}
else
{
uriString = uri2.GetLeftPart(UriPartial.Path);
////this removes the query string
//uriString.Substring(0, uriString.Length - uri2.Query.Length);
Uri uritemp = new Uri(uriString);
if (uritemp.Query.Length > 0)
{
string fred = "There is a problem";
}
//changed to ignore case
if (string.Equals(leftPart, uriString, StringComparison.OrdinalIgnoreCase))
{
e.IsValid = true;
}
else
{
e.Message = string.Format("The value of the ExpectedResponseUrl property '{0}' does not equal the actual response URL '{1}'. QueryString parameters were ignored.", new object[] { uriString, leftPart });
e.IsValid = false;
}
}
}
}
}