找不到实体的geckodriver问题

时间:2019-04-15 05:49:15

标签: c# selenium-webdriver geckodriver appveyor

我正在尝试进行硒测试,这是失败的代码

public virtual void Init()
    {

        try
        {

            WebDriver = new FirefoxDriver();

        }
        catch (WebDriverException e1)
        {
            Console.WriteLine($"1st attempt failed {e1.Message}");
            var ffPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
            if (File.Exists(ffPath))
            {
                try
                {
                    var service = FirefoxDriverService.CreateDefaultService();
                    service.FirefoxBinaryPath = ffPath;
                    WebDriver = new FirefoxDriver(service);
                }
                catch (WebDriverException e2)
                {
                    Console.WriteLine($"2ND attempt failed {e2.Message}");
                    try
                    {

                        WebDriver = new ChromeDriver();

                    }
                    catch (Exception e3)
                    {
                        Console.WriteLine($"3rd attempt failed {e3.Message}");
                        Assert.Fail(e3.Message);
                    }
                }
            }
            else
            {
                throw new Exception("Nothing working");
            }
        }

        WebDriver.Manage().Window.Maximize();

    }

我得到找不到实体错误,这种情况仅在通过名为appveyor的CI CD部署代码时发生一次。如果我重新运行部署,则测试运行正常。因此,基本上内联部署失败。

1 个答案:

答案 0 :(得分:0)