c# - Firefox 通过 GeckoDriver 在 Selenium 3.0.1 中的 .Quit() 上抛出异常

标签 c# azure selenium firefox geckodriver

上下文:Firefox 50.0.2 64 位、C#、Visual Studio 2015、Windows Server 2012 R2、Azure、ClearScript.V8.5.4.7、Selenium.Mozilla.Firefox.Webdriver.0.6.0.1、Selenium.WebDriver.GeckoDriver。 Win64.0.11.1

我使用 ClearScript 来包装 Selenium 对象以在 JavaScript 中使用,即

    static JScriptEngine JSengine = null;
    ...
    JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);
    ...
    JSengine.AddHostType("CSFirefoxDriver", typeof(FirefoxDriver));
    JSengine.AddHostType("CSFirefoxOptions", typeof(FirefoxOptions));
    JSengine.AddHostType("CSFirefoxDriverService", typeof(FirefoxDriverService));

我使用以下 JS 实例化 Firefox

var driverService = CSFirefoxDriverService.CreateDefaultService();
driverService.FirefoxBinaryPath = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";
driverService.HideCommandPromptWindow = true;
driverService.SuppressInitialDiagnosticInformation = true;
var options = new CSFirefoxOptions();
driver = new CSFirefoxDriver(driverService, options, CSTimeSpan.FromSeconds(30));

匹配的退出/处置代码是

try {
  driver.Quit();
} catch (E) {
  T.Error().Send("driver.Quit() failed.");
}

try {
  driver.Dispose();
} catch (E) {
  T.Error().Send("driver.Dispose() failed.");
}

(T是一个日志对象)

当执行 .Quit() 方法调用时,我会看到以下对话框。

Demonstration of crash

如果我注释掉 .Quit(),那么我会在 .Dispose() 上得到相同的结果。

其他论坛建议在 Firefox 的首选项中关闭硬件加速。这根本没有任何区别。

geckodriver 上也存在问题有关此问题的论坛声称已进行某种修复。现在肯定还没有修复。

Windows 事件日志在这里并不是特别有用,即

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    <System>
        <Provider Name="Application Popup" Guid="{47BFA2B7-BD54-4FAC-B70B-29021084CA8F}" /> 
        <EventID>26</EventID> 
        <Version>0</Version> 
        <Level>4</Level> 
        <Task>0</Task> 
        <Opcode>0</Opcode> 
        <Keywords>0x8000000000000000</Keywords> 
        <TimeCreated SystemTime="2016-12-13T03:16:28.936810900Z" /> 
        <EventRecordID>1227958</EventRecordID> 
        <Correlation /> 
        <Execution ProcessID="5856" ThreadID="11580" /> 
        <Channel>System</Channel> 
        <Computer>VM1-SQLWEB-W12</Computer> 
        <Security UserID="S-1-5-18" /> 
    </System>
    <EventData>
        <Data Name="Caption">firefox.exe - Application Error</Data> 
        <Data Name="Message">The exception Breakpoint A breakpoint has been reached. (0x80000003) occurred in the application at location 0x880f00ef. Click on OK to terminate the program Click on CANCEL to debug the program</Data> 
    </EventData>
</Event>

我该去哪里?我可以退回到 PhantomJS,直到找到修复程序。

最佳答案

我也遇到了同样的问题,发现有人发帖here 。目前您可以降级到 Firefox 48.0.2,直到问题得到修复。

关于c# - Firefox 通过 GeckoDriver 在 Selenium 3.0.1 中的 .Quit() 上抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41113331/

相关文章:

c# - 依赖注入(inject)和库/框架

c# - 将网站发布到 Azure 云服务时,VS 2013 挂起

c# - 尝试将项目和值添加到 asp.net 中的下拉列表时出错

c# - 防止在 linq 查询中填充子表

ASP.NET 将字符编码更改为 windows-1252

java - android - sql server - 连接为空或找不到合适的驱动程序

selenium - 使用具有相同 selenium 测试的不同页面对象集

java - 无法替换表列中的值

java - 使用 Gecko 驱动程序运行我的 Selenium 脚本时出现 "org.openqa.selenium.WebDriverException: Unsupported Marionette protocol version 2"错误

c# - UnauthorizedAccessException 即使应用程序以管理员身份运行