7

Context: Firefox 50.0.2 64bit, 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

I'm using ClearScript to wrap the Selenium objects for use in JavaScript, viz

    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));

I instantiate Firefox using the following JS

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));

The matching Quit/Dispose code is

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

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

(T is a logging object)

When the .Quit() method call is executed, I get the following dialog.

Demonstration of crash

If I comment out the the .Quit() then I get the same on the .Dispose().

Other forums have suggested turning off hardware acceleration in Firefox's preferences. This has not made any difference at all.

There is also an issue on the geckodriver forum about this claiming a fix of some sort. It's certainly not fixed now.

Windows Event Log isn't particularly helpful here, viz

<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>

Where do I go from here? I can fall back to PhantomJS until a fix is found.

bugmagnet
  • 7,631
  • 8
  • 69
  • 131
  • 1
    I also had the same problem and found it to be reported https://github.com/mozilla/geckodriver/issues/375. I downgrading to firefox 48.0.2 for now until they fix it. – mosaad Dec 13 '16 at 14:12
  • I downgraded as well. https://ftp.mozilla.org/pub/firefox/releases/48.0.2/ – jibbs Dec 13 '16 at 15:23
  • @mosaad If you post that as a solution, I'll give it a check-mark. By the way, even updating to 50.1 doesn't solve the issue. – bugmagnet Dec 14 '16 at 04:09
  • what error is displayed when you run from the command line? – Corey Goldberg Jan 13 '17 at 16:14

4 Answers4

5

I had the same problem, I found that someone posted it here. For now you can downgrade to Firefox 48.0.2 until it is fixed.

mosaad
  • 2,276
  • 5
  • 27
  • 49
1

Problem appears only on windows 8.1 (I checked on win7 & wind10 and it's works properly). So you should upgrade your OS or downgrade browser.

madSound
  • 11
  • 2
  • Downgrading browser was the only path feasible. The Azure server is running Server 2012 R2 and I'm not in a position to upgrade the OS/ – bugmagnet Dec 14 '16 at 14:48
1

This issue is with webdriver.gecko.driver if used driver.quit() I got same issue with selenium-java-3.0.1, FF v 50.1.0, Eclipse Kepler, JDK1.8

Solution : Use driver.close()

Samir 007
  • 179
  • 2
  • 8
  • driver.close() is not the same as driver.quit() – Corey Goldberg Jan 13 '17 at 16:12
  • Hey Corey. You are absolutely correct that driver.close() and driver.quit() is not same. driver.quit() close all the browser instance where in driver.close() will close current browser session. But due to current limitation of gecko driver if you want to run the script in firefox then driver.close() will work without exception. – Samir 007 Jan 16 '17 at 06:02
  • almost correct. quit() kills the entire webdriver, while close() only closes the current tab/window. quit() calls close() as part of the driver's cleanup.. it's a subtle but important difference. – Corey Goldberg Jan 16 '17 at 14:26
1

USE THIS. Kill every firefox`s process and the process of the exception windows (join 2 solutions on net):

string sProcessName = "firefox";

            if (driver.Capabilities.BrowserName == sProcessName)
            {
                // Special fix for firefox because of issue https://github.com/mozilla/geckodriver/issues/173
                // Kills all firefox processes

                Process[] oProccesses = null;
                bool bFound = true;

                while (bFound == true)
                {
                    bFound = false;
                    oProccesses = System.Diagnostics.Process.GetProcessesByName(sProcessName);

                    foreach (Process oCurrentProcess in oProccesses)
                    {
                        bFound = true;
                        //oCurrentProcess.Kill();


                        int waitTimeSecs = 2;

                        bool cleanExit = oCurrentProcess.WaitForExit(waitTimeSecs * 1000);
                        if (!oCurrentProcess.HasExited)
                        {
                            oCurrentProcess.CloseMainWindow();
                            System.Threading.Thread.Sleep(2000);
                        }

                        if (!oCurrentProcess.HasExited)
                        {
                            oCurrentProcess.Kill();
                            oCurrentProcess.WaitForExit();
                            // if an exception window has popped up, that needs to be killed too

                            foreach (var process in Process.GetProcessesByName("firefox"))
                            {
                                process.CloseMainWindow();
                                System.Threading.Thread.Sleep(2000);
                                if (!process.HasExited)
                                    process.Kill();
                            }
                        }


                    }
                }
                driver.Quit();
            }