How to show user prompts from within the plugin code?

Hello @smartkuku,

We have confirmed the bug when using component settings and I have filed an issue with R&D.

In the meantime, there is a work around.

First you need to create a DUT and move the Serial from the Component Settings to the new created DUT, also in order to propagate the serial number change we need to add a private property and also call the OnPropertyChanged() method on the set, here is an example of the DUT I created:

namespace OpenTap.Plugins.MyPlugin1
{
[Display(“MyDut1”, Group: “OpenTap.Plugins.MyPlugin1”, Description: “Add a description here”)]
public class MyDut1 : Dut
{

    private string _Serial;
    [MetaData(true, "Serial")]
    [Display("Serial", Description: "Serial Number.")]
    public string Serial
    {
        get
        {
            return _Serial;
        }
        set
        {
            _Serial = value;
            OnPropertyChanged("Serial");
        }
    }

    /// <summary>
    /// Initializes a new instance of this DUT class.
    /// </summary>
    public MyDut1()
    {
        Name = "MyDUT";
        // ToDo: Set default values for properties / settings.
        Serial = "12345";
    }
}

}

Now, make sure you add at least one test that makes use of the new DUT, I created a step that shows the serial number that the user entered.

[Display("Display Serial Number", Group: "OpenTap.Plugins.MyPlugin1", Description: "Insert description here")]
public class Step : TestStep
{
    #region Settings
    public MyDut1 MyDut1 { get; set; }
    #endregion

    public Step()
    {
        // ToDo: Set default values for properties / settings.
    }

    public override void Run()
    {
        // ToDo: Add test case code.
        Log.Info("Serial: " + MyDut1.Serial);

        // If no verdict is used, the verdict will default to NotSet.
        // You can change the verdict using UpgradeVerdict() as shown below.
        UpgradeVerdict(Verdict.Pass);
    }
}

Again make sure your CSV Result listener has the following File Path string:

Results\<Serial>\<ResultName>-<Date>-<Verdict>.csv

Now make sure the Allow Metadata Prompt is enabled in Engine settings, and after running your test sequence you should get the results in the folder named as the serial number you provided on the metadata prompt.

The bug found using component settings also applies to a custom step that provides the user with a prompt to enter the serial number, so please use the method using the DUT and the Allow metadata prompt from the engine to input data from the user.

Let me know if this helps,

Carlos Montes

1 Like