0

我尝试使用现有的 selenium 插件代码和资源制作插件。我只需一个命令(用于测试)就可以制作一个插件来打开 Flipkart。我使用 selenium.open 命令代码并通过将 URL 参数的默认值输入为 (flipkart.com) 对其进行了轻微编辑。我成功地构建了我的解决方案(我确保添加了所有 nuget 包和其他必需品)现在当我尝试在我的工作室中加载插件时,我收到一个错误,提示它需要FlipkartOpen 命令的命令后缀. 谁能告诉我这个错误的原因,也许是解决它的可能解决方案?

这是错误图像:新插件的 G1ANT Studio 错误。

这是我的代码示例:

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Linq;
using System.Text;
using G1ANT.Language;
using OpenQA.Selenium;


namespace G1ANT.Addon.Flipkart.Commands
{
    [Command(Name = "Flipkart.Open", Tooltip = "This command opens flipkart in a web browser provided in the Argument.")]
    public class FlipkartOpen : Command
    {
        public FlipkartOpen(AbstractScripter scripter) : base(scripter)
        {

        }
        public class Arguments : CommandArguments
        {
            // Enter all arguments you need
            [Argument(Required = true, Tooltip = "Name of a web browser")]
            public TextStructure Type { get; set; } = new TextStructure(string.Empty);

            [Argument(DefaultVariable ="Url",  Tooltip = "Website Url")]
            public TextStructure Url { get; set; } = new TextStructure("www.flipkart.com");

            [Argument(DefaultVariable = "timeoutselenium", Tooltip = "Specifies time in milliseconds for G1ANT.Robot to wait for the command to be executed")]
            public override TimeSpanStructure Timeout { get; set; } = new TimeSpanStructure(SeleniumSettings.SeleniumTimeout);

            [Argument(Tooltip = "By default, waits until the webpage fully loads")]
            public BooleanStructure NoWait { get; set; } = new BooleanStructure(false);

            [Argument(Tooltip = "Result variable")]
            public VariableStructure Result { get; set; } = new VariableStructure("result");
        }

        

        // Implement this method
        public void Execute(Arguments arguments)
        {
            try
            {
                SeleniumWrapper wrapper = SeleniumManager.CreateWrapper(
                    arguments.Type.Value,
                    arguments.Url?.Value,
                    arguments.Timeout.Value,
                    arguments.NoWait.Value,
                    Scripter.Log,
                    Scripter.Settings.UserDocsAddonFolder.FullName);
                int wrapperId = wrapper.Id;
                OnScriptEnd = () =>
                {
                    SeleniumManager.DisposeAllOpenedDrivers();
                    SeleniumManager.RemoveWrapper(wrapperId);
                    SeleniumManager.CleanUp();
                };
                Scripter.Variables.SetVariableValue(arguments.Result.Value, new IntegerStructure(wrapper.Id));
            }
            catch (DriverServiceNotFoundException ex)
            {
                throw new ApplicationException("Driver not found", ex);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Error occured while opening new selenium instance. Url '{arguments.Url.Value}'. Message: {ex.Message}", ex);
            }
        }
    }
}
4

1 回答 1

0

要消除此错误,当您添加新类时,请在添加时在末尾写入 Command.cs。试试 FlipkartopenCommand.cs 这应该可以消除您的错误。

于 2020-07-10T11:59:15.150 回答