运行编码性能测试时出错 [英] Error running coded performance test

查看:102
本文介绍了运行编码性能测试时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在win7上使用Visual Studio 2010运行Webtest,只需加载3页并退出。我记录了这个测试,然后参数化了Web服务器,然后生成了代码。 它运行正常,但是当我运行生成的代码将其作为
编码的webtest运行时,我收到此错误:


错误    BasicAccessToSharePointSitesCoded   沙箱WebTest的   异常发生:没有上下文参数与所述WebTestContext&NBSP名称 '$ HIDDEN1 .__ SPSCEditMenu';  


在测试结果的响应标签指示该错误是线46所以这是生成到目前为止的代码的结果:


 


命名空间SandBox_WebTest {

  ;  使用系统;

   使用System.Collections.Generic;

   使用System.Text;
$
   使用Microsoft.VisualStudio.TestTools.WebTesting;

   使用Microsoft.VisualStudio.TestTools.WebTesting.Rules;

   

   

   公共课BasicAccessToSharePointSitesCoded:WebTest {

       

        public BasicAccessToSharePointSitesCoded(){

            this.Context.Add(QUOT; WebServer1"," HTTP:// intsystemtest");

          &NBSP ; this.Context.Add(QUOT; WebServer2"," HTTP://它");

          &NBSP ; this.Context.Add(QUOT; WebServer3"," HTTP:// thecommons");

          &NBSP ; this.PreAuthenticate = true;

        }
       

       公共覆盖IEnumerator< WebTestRequest> GetRequestEnumerator(){

            //初始化适用于WebTest中所有请求的验证规则

           如果((this.Context.ValidationLevel> = Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low)){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; ValidateResponseUrl validationRule1 =新ValidateResponseUrl();

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; this.ValidateResponse + =新的EventHandler< ValidationEventArgs>(validationRule1.Validate);

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; }
           如果((this.Context.ValidationLevel> = Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low)){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; ValidationRuleResponseTimeGoal validationRule2 =新ValidationRuleResponseTimeGoal();

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; validationRule2.Tolerance = 0D;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; this.ValidateResponseOnPageComplete + =新的EventHandler< ValidationEventArgs>(validationRule2.Validate);

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; }


            WebTestRequest request1 =新WebTestRequest((this.Context [" WebServer1"]。的ToString()+ QUOT; /"));

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP; request1.ExpectedResponseUrl =(this.Context [" WebServer1"]的ToString()+"。/Pages/Default.aspx");

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; WebTestRequest request1Dependent1 =新WebTestRequest((this.Context [" WebServer1"]的ToString()+"。/Pages/Default.aspx"));

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; request1Dependent1.ThinkTime = 6;

            request1Dependent1.Method =" POST";

            FormPostHttpBody request1Dependent1Body =新FormPostHttpBody();

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; request1Dependent1Body.FormPostParameters.Add(QUOT; __ SPSCEditMenu" ;, this.Context [" $ HIDDEN1 .__ SPSCEditMenu"]的ToString());


什么这里发生和如何解决其?

解决方案

您好,


问题似乎是结果从当涉及到"request1Dependent1Body.FormPostParameters.Add该web测试引擎无法找到上下文参数(QUOT; __ SPSCEditMenu" ;, this.Context ["


HIDDEN1 .__ SPSCEditMenu" ;]。ToString());'。


如果您没有将网络测试转换为编码网络测试,只需运行录制的网络测试,是否有任何问题?如果没有问题,您是否能够在网络测试结果窗口中的"上下文"选项卡中找到上下文参数?


I have a Webtest running on win7 with Visual Studio 2010 that just loads 3 pages and quits. I recorded this test, then parameterized the web servers then generated the code.  It runs fine as recorded but when I run the generated code to run it as a coded webtest, I get this error:

Error    BasicAccessToSharePointSitesCoded    SandBox-WebTest    Exception occurred: There is no context parameter with the name '$HIDDEN1.__SPSCEditMenu' in the WebTestContext   

The response tab in the test results indicate that the error was line 46 so here is the result of generating the code up to this point:

 

namespace SandBox_WebTest {
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.VisualStudio.TestTools.WebTesting;
    using Microsoft.VisualStudio.TestTools.WebTesting.Rules;
   
   
    public class BasicAccessToSharePointSitesCoded : WebTest {
       
        public BasicAccessToSharePointSitesCoded() {
            this.Context.Add("WebServer1", "http://intsystemtest");
            this.Context.Add("WebServer2", "http://it");
            this.Context.Add("WebServer3", "http://thecommons");
            this.PreAuthenticate = true;
        }
       
        public override IEnumerator<WebTestRequest> GetRequestEnumerator() {
            // Initialize validation rules that apply to all requests in the WebTest
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low)) {
                ValidateResponseUrl validationRule1 = new ValidateResponseUrl();
                this.ValidateResponse += new EventHandler<ValidationEventArgs>(validationRule1.Validate);
            }
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low)) {
                ValidationRuleResponseTimeGoal validationRule2 = new ValidationRuleResponseTimeGoal();
                validationRule2.Tolerance = 0D;
                this.ValidateResponseOnPageComplete += new EventHandler<ValidationEventArgs>(validationRule2.Validate);
            }

            WebTestRequest request1 = new WebTestRequest((this.Context["WebServer1"].ToString() + "/"));
            request1.ExpectedResponseUrl = (this.Context["WebServer1"].ToString() + "/Pages/Default.aspx");
            WebTestRequest request1Dependent1 = new WebTestRequest((this.Context["WebServer1"].ToString() + "/Pages/Default.aspx"));
            request1Dependent1.ThinkTime = 6;
            request1Dependent1.Method = "POST";
            FormPostHttpBody request1Dependent1Body = new FormPostHttpBody();
            request1Dependent1Body.FormPostParameters.Add("__SPSCEditMenu", this.Context["$HIDDEN1.__SPSCEditMenu"].ToString());

What is happening here and how can I fix it?

解决方案

Hello,

The issue seems result from that web test engine is not able to find the context parameter when it comes to the 'request1Dependent1Body.FormPostParameters.Add("__SPSCEditMenu", this.Context["


HIDDEN1.__SPSCEditMenu"].ToString());'.

If you do not convert web test to coded web test, just simply run the recorded web test, is there any issue? If no issue, are you able to find the context parameter in Context Tab in web test result window?


这篇关于运行编码性能测试时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆