好的,因为你们中的许多 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()
.
不知道在这里做什么,任何帮助都会很好。