public override void PostRequest(object sender, PostRequestEventArgs e) { foreach (WebTestRequest depententRequest in e.Request.DependentRequests) { depententRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(rule.Validate); } }
void SetValidationEventsForDependentResponses(object sender, PostRequestEventArgs e) { foreach (WebTestRequest depententRequest in e.Request.DependentRequests) { depententRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(depententRequest_ValidateResponse); } }
void SetValidationEventsForDependentResponses(object sender, PostRequestEventArgs e) { foreach (WebTestRequest depententRequest in e.Request.DependentRequests) { depententRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(depententRequest_ValidateResponse); } }
public override void PostRequest(object sender, PostRequestEventArgs e) { object datafileDBConnectionString; string DBConnectionValue = null; object LastnameSearchString; string LastnameSearchValue = null; object ULNInsertString; string ULNInsertValue = null; //Get DB Connection values from Test Data File if (e.WebTest.Context.TryGetValue(DBConnectionDataFile, out datafileDBConnectionString)) { DBConnectionValue = datafileDBConnectionString.ToString(); //e.WebTest.AddCommentToResult("DB Connection = " + DBConnectionValue); //e.WebTest.AddCommentToResult("LastnameUpdate = " + e.WebTest.Context[LastnameSearch]); //e.WebTest.AddCommentToResult("ULNInsert = " + e.WebTest.Context[ULNInsert]); var webcontextparameters = e.WebTest.Context; webcontextparameters.Add("dbconnectionstring", DBConnectionValue); } else { throw new WebTestException(DBConnectionDataFile + "' - Test Data File' not found"); } // Get LastnameSearch value if (e.WebTest.Context.TryGetValue(LastnameSearch, out LastnameSearchString)) { LastnameSearchValue = LastnameSearchString.ToString(); //e.WebTest.AddCommentToResult("Lastname Context Parameter = " + LastnameSearchValue); } else { throw new WebTestException(LastnameSearch + " not found"); } // Get ULNInsert Value if (e.WebTest.Context.TryGetValue(ULNInsert, out ULNInsertString)) { ULNInsertValue = ULNInsertString.ToString(); //e.WebTest.AddCommentToResult("ULN Context Parameter = " + ULNInsertValue); } else { throw new WebTestException(ULNInsert + " not found"); } //Insert ULN into database DBUpdate(LastnameSearchValue, ULNInsertValue, DBConnectionValue); }
public override void PostRequest(object sender, PostRequestEventArgs e) { if (!_preRequest) { string[] values = _values.Split(_separator); Random rd = new Random(); int i = rd.Next(0, values.Length); if (values.Length > 1) { int aux = i; while (aux == i) { i = rd.Next(0, values.Length); } } string value = values[i]; value = ReplaceContextVar(value, e.WebTest); e.WebTest.Context[_contextVariable] = value; } base.PostRequest(sender, e); }
public override void PostRequest(object sender, PostRequestEventArgs e) { foreach (WebTestRequest dependentRequest in e.Request.DependentRequests) { dependentRequest.Cache = AllowCaching; } }
public override void PostRequest(object sender, PostRequestEventArgs e) { foreach (WebTestRequest depententRequest in e.Request.DependentRequests) { depententRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(rule.Validate); } }
public override void PostRequest(object sender, PostRequestEventArgs e) { WebTestRequestCollection depsToRemove = new WebTestRequestCollection(); // Note, you can't modify the collection inside a foreach, hence the second collection // requests to remove. foreach (WebTestRequest r in e.Request.DependentRequests) { if (!string.IsNullOrEmpty(FilterDependentRequestsThatStartWith)) { if (r.Url.StartsWith(FilterDependentRequestsThatStartWith)) { depsToRemove.Add(r); } } else if (!string.IsNullOrEmpty(FilterDependentRequestsThatEndWith)) { if (r.Url.EndsWith(FilterDependentRequestsThatEndWith)) { depsToRemove.Add(r); } } } foreach (WebTestRequest r in depsToRemove) { e.WebTest.AddCommentToResult(string.Format("Removing dependent: {0}", r.Url)); e.Request.DependentRequests.Remove(r); } }
public override void PostRequest(object sender, PostRequestEventArgs e) { if (e.ResponseExists && !e.Response.IsBodyEmpty) { File.WriteAllBytes(this.FileName, e.Response.BodyBytes); } }
public override void PostRequest(object sender, PostRequestEventArgs e) { if (!_preRequest) { string ind = _Index; if (_Index.Contains("{{")) { ind = e.WebTest.Context[_Index.Replace("{{", "").Replace("}}", "")].ToString(); } string val = ""; string varName = ""; if (_useGroups) { varName = _Variable + "_" + ind + "_g" + _groupIndex; } else { varName = _Variable + "_" + ind; } if (e.WebTest.Context.ContainsKey(varName)) { val = e.WebTest.Context[varName].ToString(); } e.WebTest.Context[_ResultVariable] = val; } base.PostRequest(sender, e); }
public override void PostRequest(object sender, PostRequestEventArgs e) { base.PostRequest(sender, e); ITestContext context = e.WebTest.Context[TestContextConst.ContextKey] as ITestContext; context.SetEventArgs(e); //TestContext.Context.SetEventArgs(e); }
public override void PostRequest(object sender, PostRequestEventArgs e) { DateTime epoch = new DateTime(1970, 1, 1); UInt64 unix = (UInt64)DateTime.UtcNow.Subtract(epoch).TotalMilliseconds; e.WebTest.Context[_contextVariable] = unix.ToString(); base.PostRequest(sender, e); }
public override void PostRequest(object sender, PostRequestEventArgs e) { if (!_preRequest && e.Response.StatusCode != System.Net.HttpStatusCode.Redirect) { int val = int.Parse(e.WebTest.Context[_Variable].ToString()); e.WebTest.Context[_Variable] = val + _incValue; } base.PostRequest(sender, e); }
private async void WebTestRequest_PostRequest(object sender, PostRequestEventArgs e) { var connection = lazyConnection.Value; var redisCache = connection.GetDatabase(); var json = e.Response.BodyString; var customer = JsonConvert.DeserializeObject <Customer>(json); await redisCache.StringSetAsync(customer.Id, customer.Address.State); }
public override void PostRequest(object sender, PostRequestEventArgs e) { if (AppSettingsPlugin.DisableDependentCaching) { foreach (WebTestRequest dependentRequest in e.Request.DependentRequests) { dependentRequest.Cache = false; } } base.PostRequest(sender, e); }
public override void PostRequest(object sender, PostRequestEventArgs e) { string body = e.Response.BodyString; // Looking for requests in a specific class. string pattern = "\\bclass=\"nav__link-[23]\" +href=\"(/[^\"]*)\""; // The URL is in this capture: ^^^^^^^^^ MatchCollection matches = Regex.Matches(body, pattern); int randomIndex = GetARandomNumber(matches.Count); // Above will get a value 0 <= randomIndex < matches.Count e.WebTest.Context[ContextParameter] = matches[randomIndex].Groups[1].Value; }
public override void PostRequest(object sender, PostRequestEventArgs e) { byte[] bb = e.Response.BodyBytes; string ss = e.Response.BodyString; e.WebTest.AddCommentToResult( "BodyBytes is " + bb == null ? " null" : bb.Length.ToString() + " bytes"); e.WebTest.AddCommentToResult( "BodyString is " + ss == null ? "null" : ss.Length.ToString() + " chars"); // Use bb or ss. }
public override void PostRequest(object sender, PostRequestEventArgs e) { WebTestRequestCollection depsToRemove = new WebTestRequestCollection(); // Note, you can't modify the collection inside a foreach, hence the second collection // requests to remove. foreach (WebTestRequest r in e.Request.DependentRequests) { if (!string.IsNullOrEmpty(FilterDependentRequestsThatStartWith) && r.Url.StartsWith(FilterDependentRequestsThatStartWith)) { depsToRemove.Add(r); } if (!string.IsNullOrEmpty(FilterDependentRequestsThatEndWith) && r.Url.EndsWith(FilterDependentRequestsThatEndWith)) { depsToRemove.Add(r); } if (!string.IsNullOrEmpty(FilterDependentRequestsThatContain) && r.Url.Contains(FilterDependentRequestsThatContain)) { depsToRemove.Add(r); } } foreach (WebTestRequest r in depsToRemove) { e.Request.DependentRequests.Remove(r); } WebTestDependentFilter DepFilter = new WebTestDependentFilter(); DepFilter.FilterDependentRequestsThatContain = FilterDependentRequestsThatContain; DepFilter.FilterDependentRequestsThatEndWith = FilterDependentRequestsThatEndWith; DepFilter.FilterDependentRequestsThatStartWith = FilterDependentRequestsThatStartWith; foreach (WebTestRequest r in e.Request.DependentRequests) { r.PreRequest += new EventHandler <PreRequestEventArgs>(DepFilter.PreRequest); r.PostRequest += new EventHandler <PostRequestEventArgs>(DepFilter.PostRequest); } }
public override void PostRequest(object sender, PostRequestEventArgs e) { Random rd = new Random(); int n = rd.Next(_minValue, _maxValue + 1); if (_maxValue != _minValue) { int aux = n; while (aux == n) { n = rd.Next(_minValue, _maxValue + 1); } } e.WebTest.Context[_contextVariable] = n; base.PostRequest(sender, e); }
public override void PostRequest(object sender, PostRequestEventArgs e) { base.PostRequest(sender, e); int stepNo = (int)e.WebTest.Context[STEP_NO_KEY]; e.WebTest.Context[STEP_NO_KEY] = stepNo + 1; // When cookies are issues domain wide like .static.dropthings.com, it does not get // added to the Cookie container properly so that the cookie is sent out on static.dropthings.com // visit foreach (Cookie cookie in e.Response.Cookies) { if (cookie.Domain.StartsWith(".")) { CookieContainer container = e.WebTest.Context.CookieContainer; cookie.Domain = cookie.Domain.TrimStart('.'); //container.Add(new Uri(e.Response.ResponseUri.GetLeftPart(UriPartial.Authority)), cookie); container.Add(cookie); } } }
public override void PostRequest(object sender, PostRequestEventArgs e) { Random rd = new Random(); string cardNumber = ""; if (_CardType.Equals("1")) { cardNumber = Auxiliary.RandomCreditCardNumberGenerator.GenerateVisaNumber(); } else if (_CardType.Equals("2")) { cardNumber = Auxiliary.RandomCreditCardNumberGenerator.GenerateMasterCardNumber(); } else if (_CardType.Equals("3")) { cardNumber = Auxiliary.RandomCreditCardNumberGenerator.GenerateAmexNumber(); } else if (_CardType.Equals("4")) { cardNumber = Auxiliary.RandomCreditCardNumberGenerator.GenerateDinersNumber(); } else { cardNumber = Auxiliary.RandomCreditCardNumberGenerator.GenerateGenericNumber(); } string securityCode = rd.Next(100, 1000).ToString(); string expMonth = rd.Next(1, 13).ToString("00"); string expYear = rd.Next(DateTime.Now.Year + 1, DateTime.Now.Year + 11).ToString(); string CPF = Auxiliary.AuxFunctions.GerarCpf(); e.WebTest.Context[_CardNumberVariable] = cardNumber; e.WebTest.Context[_SecurityCodeVariable] = securityCode; e.WebTest.Context[_ExpirationMonthVariable] = expMonth; e.WebTest.Context[_ExpirationYearVariable] = expYear; e.WebTest.Context[_CPFVariable] = CPF; base.PostRequest(sender, e); }
public override void PostRequest(object sender, PostRequestEventArgs e) { base.PostRequest(sender, e); int stepNo = (int)e.WebTest.Context[STEP_NO_KEY]; e.WebTest.Context[STEP_NO_KEY] = stepNo + 1; // When cookies are issues domain wide like .static.dropthings.com, it does not get // added to the Cookie container properly so that the cookie is sent out on static.dropthings.com // visit foreach (Cookie cookie in e.Response.Cookies) { if (cookie.Domain.StartsWith(".")) { CookieContainer container = e.WebTest.Context.CookieContainer; cookie.Domain = cookie.Domain.TrimStart('.'); //container.Add(new Uri(e.Response.ResponseUri.GetLeftPart(UriPartial.Authority)), cookie); container.Add(cookie); } } }
private void CurrentRequestOnPostRequest(object sender, PostRequestEventArgs postRequestEventArgs) { if (currentWebTestOutcome == Outcome.Pass) { postRequestEventArgs.WebTest.Outcome = Outcome.Pass; } }
public override void PostRequest(object sender, PostRequestEventArgs e) { base.PostRequest(sender, e); }
public override void PostRequest(object sender, PostRequestEventArgs e) { Console.WriteLine(e.WebTest.Context.AgentName); }
public override void PostRequest(object sender, PostRequestEventArgs e) { MessageBox.Show(e.WebTest.Context.AgentName); }
void request1_PostRequest(object sender, PostRequestEventArgs e) { String responseBody = e.Response.BodyString; }
public void Test_PostRequest(object sender, PostRequestEventArgs e) { //var sharedThreadData = CustomDS.Instance.GetCreateInvoiceUserData_Web(Convert.ToInt32(e.WebTest.Context.WebTestUserId)); SharedThreadData threadData = CommonFunctions.getThreadDataByScenarioName(Convert.ToInt32(e.WebTest.Context.WebTestUserId), e.WebTest.Name); if (e.Request.Url == e.WebTest.Context["LoginMain"].ToString() + "/") { List <string> list = new List <string>(e.Response.Headers.AllKeys); if (ScopeValue == "" && StateValue == "" && NonceValue == "") { string location = e.Response.Headers["Location"].ToString(); if (!location.Contains("msg=loggedoff")) { string[] words = location.Split('&'); //Extracting Scope Value string Scopeword = words[4].ToString(); string[] ScopeVariable = Scopeword.Split('='); string correctscope = ScopeVariable[1].ToString(); ScopeValue = correctscope.Replace('+', ' '); //Extracting State Value string Stateword = words[5].ToString(); string[] stateVariable = Stateword.Split('='); StateValue = stateVariable[1].ToString(); //Extracting Nonce Value string Nonceword = words[6].ToString(); string[] NonceVariable = Nonceword.Split('='); NonceValue = NonceVariable[1].ToString(); } } if (list.Contains("Set-Cookie")) { string setcookie = e.Response.Headers["Set-Cookie"].ToString(); if (setcookie.Contains("SessionId")) { string[] varcookie = setcookie.Split(';'); string cookiesplit = string.Empty; if (AssemblyLoad.enviornmentName.Equals("Perf")) { if (threadData.hasFullAccess == "0") { cookiesplit = varcookie[5].ToString();//For Perf Env } else { cookiesplit = varcookie[8].ToString(); } } else if (AssemblyLoad.enviornmentName.Equals("RC_Azure")) { if (threadData.hasFullAccess == "0") { cookiesplit = varcookie[0].ToString();//string cookiesplit = varcookie[0].ToString(); //For RC-Azure Env } else { cookiesplit = varcookie[0].ToString(); } } string[] cookiesplit1 = cookiesplit.Split('&'); string SID = cookiesplit1[0].ToString(); string OrgID = cookiesplit1[1].ToString(); //Extracting Session ID value string[] SIDSplit = SID.Split('='); SessionIdValue = SIDSplit[2].ToString(); threadData.SessionId = SessionIdValue; //Extracting Organisation ID value string[] OrgIDSplit = OrgID.Split('='); OrgIdValue = OrgIDSplit[1].ToString(); threadData.OrganizationId = OrgIdValue; string BNES_SIDCookie = string.Empty; if (AssemblyLoad.enviornmentName.Equals("Perf")) { if (threadData.hasFullAccess == "0") { BNES_SIDCookie = varcookie[14].ToString();//For Perf Env } else { BNES_SIDCookie = varcookie[20].ToString(); } string[] BNES_SIDArray = BNES_SIDCookie.Split('='); string BNES_SID = BNES_SIDArray[1].ToString() + "="; threadData.BNES_SID = BNES_SID; } else if (AssemblyLoad.enviornmentName.Equals("RC_Azure")) { /*if (threadData.hasFullAccess == "0") * BNES_SIDCookie = varcookie[0].ToString();//For RC-Azure Env * else * BNES_SIDCookie = varcookie[3].ToString(); * * string[] BNES_SIDArray = BNES_SIDCookie.Split('='); * string BNES_SID = BNES_SIDArray[1].ToString()+"="; * * threadData.BNES_SID = BNES_SID;*/ } } } } if (e.Request.Url == e.WebTest.Context["LoginMain"].ToString() + "/auth/authentication/connect/authorize") { List <string> list = new List <string>(e.Response.Headers.AllKeys); if (list.Contains("Location")) { string signin = e.Response.Headers["Location"].ToString(); if (signin.Contains("signin")) { string[] words = signin.Split('?'); string wordsign = words[1].ToString(); string[] Variable = wordsign.Split('='); SigninValue = Variable[1].ToString(); } } } if (e.Request.Url == e.WebTest.Context["AccountingURL"].ToString() + "/pay/default.aspx" && !e.Request.UrlWithQueryString.Contains("?")) { if (e.Response.BodyString.Contains("tempXml")) { List <string> extractedValues = CommonFunctions.GetBetweenList(e.Response.BodyString, "tempXml\" ID=\"tempXml\" VALUE=\"", "\"><BR>"); if (e.WebTest.Context.Keys.Contains("tempXmlId")) { e.WebTest.Context["tempXmlId"] = extractedValues.Last(); } else { e.WebTest.Context.Add("tempXmlId", extractedValues.Last()); } if (e.WebTest.Context.Keys.Contains("hdnRowCount")) { e.WebTest.Context["hdnRowCount"] = CommonFunctions.GetSingleWordBetween(e.Response.BodyString, "ID=\"hdnRowCount\" VALUE=\"", "\">"); } else { e.WebTest.Context.Add("hdnRowCount", CommonFunctions.GetSingleWordBetween(e.Response.BodyString, "ID=\"hdnRowCount\" VALUE=\"", "\">")); } if (e.WebTest.Context.Keys.Contains("hdnFromForm")) { e.WebTest.Context["hdnFromForm"] = CommonFunctions.GetSingleWordBetween(e.Response.BodyString, "ID=\"hdnFromForm\" VALUE=\"", "\">"); } else { e.WebTest.Context.Add("hdnFromForm", CommonFunctions.GetSingleWordBetween(e.Response.BodyString, "ID=\"hdnFromForm\" VALUE=\"", "\">")); } if (e.WebTest.Context.Keys.Contains("txtButtonPushedId")) { e.WebTest.Context["txtButtonPushedId"] = CommonFunctions.GetSingleWordBetween(e.Response.BodyString, "ID=\"txtButtonPushedId\" VALUE=\"", "\">"); } else { e.WebTest.Context.Add("txtButtonPushedId", CommonFunctions.GetSingleWordBetween(e.Response.BodyString, "ID=\"txtButtonPushedId\" VALUE=\"", "\">")); } } } }
public override void PostRequest(object sender, PostRequestEventArgs e) { base.PostRequest(sender, e); }