How to show user prompts from within the plugin code?

Hi @carlos.montes ,

Thanks for your responding. I implement this requirement by following your steps and found a possible bug.

Let me first describe the possible bug.

The folder is created by name defined in last run not current run. Here is the procedure, at first time, I run the test plan, and enter the serial “1000”, the folder name is “1000”; run the test plan again, the serial number I entered is 1001, the folder name is still “1000”; run the test plan again, enter serial number “1002”, the folder name is “1001”.

This bug exists when I using the test step to enter the serial number or using the “Allow Metadata Prompt”.

Below is the detail How I implement the code

    [SettingsGroupAttribute("Bench", Profile: true)]
    [Display("DUT Custom Settings", Description: "A collection of different instances of DUT settings.")]
    [XmlInclude(typeof(CustomBenchSettings))]
    public class DUTCustomSetting : ComponentSettings<DUTCustomSetting>
    {
        // No code necessary.
        [MetaData(true)]
        [Display("Serial", Description: "Serial Number.")]
        public string Serial { get; set; }

        public DUTCustomSetting()
        {
            Serial = "";
        }
    }

    [Display("Please enter serial number")]
    class SNInputDialog
    {
        // Serial number to be entered by the user.
        [Display("Serial Number")]
        public string SerialNumber { get; set; }
    }

    // This example shows how to use UserInput to get user input. 
    // In TAP GUI it appears as a dialog box. In TAP CLI the user is prompted.
    [Display("Serial Input", Groups: new[] { "Examples", "Plugin Development", "GUI" },
        Description: "This example shows how to use UserInput.")]
    public class SerialInput : TestStep
    {
        [Display("Use Timeout", "Enabling this will make the dialog close after an amount of time.", Group: "Timeout", Order: 1)]
        public bool UseTimeout { get; set; }

        [EnabledIf("UseTimeout", true)]
        [Unit("s")]
        [Display("Timeout", "The dialog closes after this time.", Group: "Timeout", Order: 2)]
        public double Timeout { get; set; }

        public SerialInput()
        {
            UseTimeout = true;
            Timeout = 1000;
            Rules.Add(() => Timeout > 0, "Timeout must > 0s.", "Timeout");
        }

        public override void Run()
        {
            try
            {
                var timeout = UseTimeout ? TimeSpan.FromSeconds(Timeout) : TimeSpan.Zero;

                // Dialog/prompt where user has option to select "OK" or "Cancel".
                // The message/query is set by the Message property. Selection options are defined by WaitForInputResult.

                var snDialog = new SNInputDialog();
                // Dialog/prompt where user has option to enter a string as DUT S/N
                UserInput.Request(snDialog, timeout);
                DUTCustomSetting.Current.Serial = snDialog.SerialNumber;
                
                Log.Info("DUT S/N: {0}", DUTCustomSetting.Current.Serial);
            }
            catch (TimeoutException)
            {
                Log.Info("User did not click. Are they sleeping?");
            }
        }
    }