C# 使用Ranorex新荷载的荷载性能

C# 使用Ranorex新荷载的荷载性能,c#,ranorex,neoload,C#,Ranorex,Neoload,我正在尝试使用NeoLoad来提高Ranorex的性能,这是我的代码我有一个Ranorex代码和NeoLoad代码,它调用要执行的Ranorex代码。当我运行第二个代码时,出现以下错误: 没有可用的方案名称。请设置有效的新加载方案名称。我需要运行第二个代码,在Ranorex上使用Neoload包执行一些应用程序性能监视 第一个代码: using System; using System.Collections.Generic; using System.Text; using System.Te

我正在尝试使用NeoLoad来提高Ranorex的性能,这是我的代码我有一个Ranorex代码和NeoLoad代码,它调用要执行的Ranorex代码。当我运行第二个代码时,出现以下错误: 没有可用的方案名称。请设置有效的新加载方案名称。我需要运行第二个代码,在Ranorex上使用Neoload包执行一些应用程序性能监视

第一个代码:

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;

using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
using Ranorex.Core.Repository;

namespace NewOpe.NeoLoad.Modules
{
#pragma warning disable 0436 //(CS0436) The type 'type' in 'assembly'      conflicts with the imported type 'type2' in 'assembly'. Using the type defined in 'assembly'.
/// <summary>
///The loadrecord recording.
/// </summary>
[TestModule("0f400fed-c562-4ef4-99fb-40ee81b4fa59", ModuleType.Recording, 1)]
public partial class loadrecord : ITestModule
{
    /// <summary>
    /// Holds an instance of the NewOpe.NewOpeRepository repository.
    /// </summary>
    public static NewOpe.NewOpeRepository repo = NewOpe.NewOpeRepository.Instance;

    static loadrecord instance = new loadrecord();

    /// <summary>
    /// Constructs a new instance.
    /// </summary>
    public loadrecord()
    {
    }

    /// <summary>
    /// Gets a static instance of this recording.
    /// </summary>
    public static loadrecord Instance
    {
        get { return instance; }
    }

#region Variables

#endregion

    /// <summary>
    /// Starts the replay of the static recording <see cref="Instance"/>.
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCode("Ranorex", "8.0")]
    public static void Start()
    {
        TestModuleRunner.Run(Instance);
    }

    /// <summary>
    /// Performs the playback of actions in this recording.
    /// </summary>
    /// <remarks>You should not call this method directly, instead pass the module
    /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
    /// that will in turn invoke this method.</remarks>
    [System.CodeDom.Compiler.GeneratedCode("Ranorex", "8.0")]
    void ITestModule.Run()
    {
        Mouse.DefaultMoveTime = 300;
        Keyboard.DefaultKeyPressTime = 100;
        Delay.SpeedFactor = 1.00;

        Init();

        Report.Log(ReportLevel.Info, "Application", "Run application 'C:\\Users\\Ahmed Abd El Nasser\\Desktop\\dist\\run.bat' with arguments '' in normal mode.", new RecordItemIndex(0));
        Host.Local.RunApplication("C:\\Users\\Ahmed Abd El Nasser\\Desktop\\dist\\run.bat", "", "C:\\Users\\Ahmed Abd El Nasser\\Desktop\\dist", false);
        Delay.Milliseconds(0);

        Report.Log(ReportLevel.Info, "Delay", "Waiting for 1m.", new RecordItemIndex(1));
        Delay.Duration(60000, false);

        Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'FormOsseoViewRelease2Sprint12.JLayeredPane1.CUsersAhmedAbdElNasserDesktopGha' at 49;12.", repo.FormOsseoViewRelease2Sprint12.JLayeredPane1.CUsersAhmedAbdElNasserDesktopGhaInfo, new RecordItemIndex(2));
        repo.FormOsseoViewRelease2Sprint12.JLayeredPane1.CUsersAhmedAbdElNasserDesktopGha.Click("49;12");
        Delay.Milliseconds(200);

        Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'FormOsseoViewRelease2Sprint12.JLayeredPane1.Both' at 10;13.", repo.FormOsseoViewRelease2Sprint12.JLayeredPane1.BothInfo, new RecordItemIndex(3));
        repo.FormOsseoViewRelease2Sprint12.JLayeredPane1.Both.Click("10;13");
        Delay.Milliseconds(200);
使用系统;
使用System.Collections.Generic;
使用系统文本;
使用System.Text.RegularExpressions;
使用系统图;
使用系统线程;
使用WinForms=System.Windows.Forms;
使用Ranorex;
使用Ranorex.Core;
使用Ranorex.Core.Testing;
使用Ranorex.Core.Repository;
名称空间NewOpe.NeoLoad.Modules
{
#pragma warning disable 0436//(CS0436)“assembly”中的类型“type”与“assembly”中导入的类型“type2”冲突。使用“assembly”中定义的类型。
/// 
///loadrecord正在录制。
/// 
[测试模块(“0f400fed-c562-4ef4-99fb-40ee81b4fa59”,模块类型记录,1)]
公共部分类装入记录:ITestModule
{
/// 
///保存NewOpe.NewOperatePository存储库的实例。
/// 
public static NewOpe.NewOpeRepository repo=NewOpe.NewOpeRepository.Instance;
静态loadrecord实例=新建loadrecord();
/// 
///构造一个新实例。
/// 
公共加载记录()
{
}
/// 
///获取此录制的静态实例。
/// 
公共静态loadrecord实例
{
获取{return instance;}
}
#区域变量
#端区
/// 
///开始静态录制的重播。
/// 
[System.CodeDom.Compiler.GeneratedCode(“Ranorex”,“8.0”)]
公共静态void Start()
{
TestModuleRunner.Run(实例);
}
/// 
///执行此录制中动作的回放。
/// 
///不应直接调用此方法,而应传递模块
///方法的实例
///这将反过来调用此方法。
[System.CodeDom.Compiler.GeneratedCode(“Ranorex”,“8.0”)]
void ITestModule.Run()
{
Mouse.DefaultMoveTime=300;
Keyboard.DefaultKeyPressTime=100;
延迟速度系数=1.00;
Init();
Report.Log(ReportLevel.Info,“Application”,“运行应用程序”C:\\Users\\Ahmed Abd El Nasser\\Desktop\\dist\\Run.bat“,在正常模式下带有参数“”,新的RecordItemIndex(0));
Host.Local.RunApplication(“C:\\Users\\Ahmed Abd El-Nasser\\Desktop\\dist\\run.bat”,“C:\\Users\\Ahmed Abd El-Nasser\\Desktop\\dist”,false);
延迟。毫秒(0);
Report.Log(ReportLevel.Info,“Delay”,“Waiting for 1m.”,新的RecordItemIndex(1));
延迟。持续时间(60000,假);
Report.Log(ReportLevel.Info,“鼠标”,“鼠标左键单击项目'FormOsseoViewRelease2Sprint12.JLayeredPane1.CUsersAhmedAbdElNasserDesktopGha'位于49;12.”,repo.FormOsseoViewRelease2Sprint12.JLayeredPane1.CUsersAhmedAbdElNasserDesktopGha,新记录项索引(2));
repo.FormOsseoViewRelease2Sprint12.JLayeredPane1.CUsersAhmedAbdElNasserDesktopGha.Click(“49;12”);
延迟。毫秒(200);
Report.Log(ReportLevel.Info,“鼠标”,“鼠标左键单击项目”FormOsseoViewRelease2Sprint12.JLayeredPane1.10;13“。repo.FormOsseoViewRelease2Sprint12.JLayeredPane1.BothInfo,新记录项索引(3));
repo.FormOsseoViewRelease2Sprint12.JLayeredPane1.两者。单击(“10;13”);
延迟。毫秒(200);
第二个代码:

using System;
using System.Globalization;
using Ranorex.Core.Testing;

namespace Ranorex.NeoLoad
{
/// <summary>
/// Starts a NeoLoad test
/// </summary>
/// <remarks>
/// A NeoLoad test can only be started, when a connection to the runtime and data exchange API was
/// established prior.
/// </remarks>
    [TestModule("1702CBFB-DA15-4C42-B6C4-6FCBA8DAE96F", ModuleType.UserCode, 1)]
    public class StartNeoLoadTest : ITestModule
    {
    // For testing, make it mockable
    internal static INeoloadApi api = NeoloadApi.Instance;

    /// <summary>
    /// Check interval for operations that can timeout in the format 'hh:mm:ss'.
    /// This interval needs to be smaller than the timeout.
    /// </summary>
    [TestVariable("29B0EB4D-D82E-4DDA-8ABB-355734B346D2")]
    public string Interval { get; set; }
    /// <summary>
    /// Timeout for the connect operation in the format 'hh:mm:ss'.
    /// </summary>
    [TestVariable("7E6AAB81-CA2F-4084-A2B2-C0B8792122A1")]
    public string Timeout { get; set; }

    /// <summary>
    /// The name of the scenario. Use this info tho identify the collected data on the NeoLoad server system.
    /// </summary>
    [TestVariable("7242C624-2E81-447E-A148-533E4BB082BE")]
    public string Scenario { get; set; }

    public StartNeoLoadTest()
    {
        this.Interval = "00:00:10";
        this.Timeout = "00:01:00";
    }

    void ITestModule.Run()
    {
        if (string.IsNullOrWhiteSpace(this.Scenario))
        {
            throw new InvalidOperationException("No scenario name available. Please set a valid NeoLoad scenario name.");
        }


        try
        {
            const string fmt = @"hh\:mm\:ss";
            var timeout = TimeSpan.ParseExact(this.Timeout, fmt, CultureInfo.InvariantCulture);
            var interval = TimeSpan.ParseExact(this.Interval, fmt, CultureInfo.InvariantCulture);

            if (timeout < interval)
            {
                throw new ArgumentException(string.Format("The given timeout of '{0}' is smaller than the interval with a value of '{1}', but interval has to be smaller than timeout.",
                    timeout.ToString(fmt), interval.ToString(fmt)));
            }

            api.StartNeoLoadTest(this.Scenario, timeout, interval);
        }
        catch (FormatException ex)
        {
            throw new Exception("'Timeout' or 'Interval' was specified with invalid format. Please use the format 'hh:mm:ss' e.g. '00:01:10' for one minute and ten seconds." + ex);
        }
    }
}
使用系统;
利用制度全球化;
使用Ranorex.Core.Testing;
名称空间Ranorex.NeoLoad
{
/// 
///开始新加载测试
/// 
/// 
///只有在连接到运行时和数据交换API时,才能启动新加载测试
///事先确定的。
/// 
[TestModule(“1702CBFB-DA15-4C42-B6C4-6FCBA8DAE96F”,ModuleType.UserCode,1)]
公共类StartNodeLoadTest:ITestModule
{
//对于测试,使其可模仿
内部静态INEOLADAPI api=NeoloadApi.Instance;
/// 
///检查格式为“hh:mm:ss”的操作的超时间隔。
///此间隔需要小于超时。
/// 
[测试变量(“29B0EB4D-D82E-4DDA-8ABB-355734B346D2”)]
公共字符串间隔{get;set;}
/// 
///格式为“hh:mm:ss”的连接操作超时。
/// 
[测试变量(“7E6AAB81-CA2F-4084-A2B2-C0B8792122A1”)]
公共字符串超时{get;set;}
/// 
///场景的名称。使用此信息可识别NeoLoad服务器系统上收集的数据。
/// 
[测试变量(“7242C624-2E81-447E-A148-533E4BB082BE”)]
公共字符串方案{get;set;}
公共启动NEOLOADTEST()
{
此.Interval=“00:00:10”;
this.Timeout=“00:01:00”;
}
void ITestModule.Run()
{
if(string.IsNullOrWhiteSpace(this.Scenario))
{
抛出新的InvalidOperationException(“没有可用的方案名称。请设置有效的新加载方案名称”);
}
尝试
{
常量字符串fmt=@“hh\:mm\:ss”;
var timeout=TimeSpan.ParseExact(this.timeout,fmt,CultureInfo.InvariantCulture);
var interval=TimeSpan.ParseExact(this.interval、fmt、CultureInfo.InvariantCulture);
if(超时<间隔)
{
抛出新ArgumentException(string.Format)(“{0}的给定超时小于值为{1}的间隔,但间隔必须小于超时。”,
timeout.ToString(fmt)、interval.ToString(fmt));
}
api.StartNeoLoadTest(这个场景,超时,间隔);
}
捕获(格式化异常)
{
抛出新异常(“'Timeout'或'Interval'指定的格式无效。请使用格式'hh:mm:ss'例如'00:01:10'持续一分十秒。”+ex);
}
}
}
}

我知道这是一场相当激烈的比赛