【发布时间】:2023-04-04 23:24:02
【问题描述】:
好吧,许多 webdriver 测试人员都知道 Firefox 47 的发布破坏了 Webdriver.FirefoxDriver。我能找到的所有文档都告诉我,新的 FirefoxDriver 是 Marionette。
所以我已经从https://github.com/mozilla/geckodriver/releases 下载了最新的可执行文件 重命名为wires.exe 并移至我的测试目录。
这是我的设置方法
[TestFixture("chrome")]
[TestFixture("firefox")]
//[TestFixture("internet explorer")]
[Category("ExistingUser")]
public class ExistingUserTestSuite
{
public string browser;
public IWebDriver Driver { get; set; }
public UserInfo User { get; set; }
private static readonly log4net.ILog log = log4net.LogManager.GetLogger("ExistingUserTest");
public ExistingUserTestSuite(string browser)
{
this.browser = browser;
}
[OneTimeSetUp]
public void SetUp()
{
switch (browser)
{
case "chrome":
Driver = new ChromeDriver();
break;
case "firefox":
FirefoxOptions op1 = new FirefoxOptions();
op1.IsMarionette = true;
op1.AddAdditionalCapability("marionette", true);
Driver = new FirefoxDriver(op1);
break;
当我尝试运行时,出现以下异常。当我开始测试时,我可以看到wire.exe 进程正在进程资源管理器中运行。
Test Name: ChangePlan
Test FullName: POMAuctivaTest.TestSuite.ExistingUserTestSuite("firefox").ChangePlan
Test Source: c:\git\POMAuctivaTest\POMAuctivaTest.TestSuite\ExistingUserTestSuite.cs : line 359
Test Outcome: Failed
Test Duration: 0:00:00.0000001
Result Message: OneTimeSetUp: System.InvalidOperationException : entity not found
这是产生异常的堆栈跟踪
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxOptions options)
at POMAuctivaTest.TestSuite.ExistingUserTestSuite.SetUp() in c:\git\POMAuctivaTest\POMAuctivaTest.TestSuite\ExistingUserTestSuite.cs:line 56
我看到的大多数建议都是关于确保您的系统路径已更新。我觉得这里不是这种情况,好像我从我的 test/bin/debug 文件夹中删除了 wire.exe 我得到了以下异常。
Test Name: ChangePlan
Test FullName: POMAuctivaTest.TestSuite.ExistingUserTestSuite("firefox").ChangePlan
Test Source: c:\git\POMAuctivaTest\POMAuctivaTest.TestSuite\ExistingUserTestSuite.cs : line 359
Test Outcome: Failed
Test Duration: 0:00:00.0000001
Result Message: OneTimeSetUp: OpenQA.Selenium.DriverServiceNotFoundException : The wires.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at https://github.com/jgraham/wires/releases.
这告诉我,我正在找到驱动程序,但由于某种原因无法创建 FirefoxDriver() 的实例。
不知道在这里做什么,任何帮助都会很好。
【问题讨论】:
标签: c# selenium firefox selenium-webdriver firefox-marionette