3

我正在尝试使用 NeoLoad 来提高 Ranorex 的性能,这是我的代码,我有一个 Ranorex 代码和 Neoload 代码,它们调用 Ranorex 代码来执行。当我运行第二个代码时,我收到此错误:没有可用的方案名称。请设置一个有效的 NeoLoad 场景名称。我需要运行第二个代码来使用 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);

第二个代码:

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);
        }
    }
}

}

4

1 回答 1

0

我知道这是一个相当古老的问题,但 Ranorex/Neoload 集成现在由 Neotys 管理,源代码可以在这里找到:

https://github.com/Neotys-Labs/Ranorex

于 2019-05-15T15:22:44.913 回答