Selenium: MarionetteDriver#quit() => java.lang.IllegalStateException: UnixUtils may not be used on Windows

Created on 1 Sep 2016  路  13Comments  路  Source: SeleniumHQ/selenium

Meta -

OS: Windows 7

Selenium Version: 2.53.1

Browser: Firefox with GeckoDriver 0.10.0.

Browser Version: 48 & nightly (both)

Expected Behavior -

MarionetteDriver.quit() should not throw an exception.

Actual Behavior -

java.lang.IllegalStateException: UnixUtils may not be used on Windows

Steps to reproduce -

Compile and run this JUnit test. It fails with an exception when reaching driver.quit().

package ihm.test;

import org.junit.Test;
import org.openqa.selenium.firefox.MarionetteDriver;

public class MarionetteTest {

    @Test
    public void assertOk() {
        MarionetteDriver driver = new MarionetteDriver();

        try {
            driver.navigate().to("http://www.chezmoicamarche.org/");
        } finally {
            driver.quit();
        }
    }
}
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
    at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:526)
    at ihm.test.MarionetteTest.assertOk(MarionetteTest.java:15)
    ...
Caused by: java.lang.IllegalStateException: UnixUtils may not be used on Windows
    at org.openqa.selenium.os.ProcessUtils.getProcessId(ProcessUtils.java:189)
    at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.getPID(UnixProcess.java:222)
    at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$300(UnixProcess.java:201)
    at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:132)
    at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155)
    at org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:196)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:94)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
    ... 30 more

C-java

Most helpful comment

I tried following and that worked for me!
Environment Details:
OS: Window 8
Firefox version: 51.0.1 (32 bit)
gecko driver: v0.13.0
Selenium: 3.0.1
Java: 1.8

Steps:

  1. Open Firefox manually.
  2. In Url bar, type about:config
  3. Search for autos
  4. set "browser.tabs.remote.autostart.2" value to false.
    (For more details, check https://support.mozilla.org/en-US/questions/1147868
  5. close firefox.
  6. From "Run", type "firefox -p"
  7. Delete any existing profile.
  8. Create new profile and Click "Start firefox"
  9. Close firefox.
  10. Now try executing your Selenium code.
`System.setProperty("webdriver.gecko.driver", "specify path to geckodriver");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();

ProfilesIni profileIni= new ProfilesIni();

FirefoxProfile profile = profileIni.getProfile("default");
capabilities.setCapability("firefox_profile", profile);
WebDriver driver=new FirefoxDriver(capabilities);

driver.get("http://google.com");
....
...
driver.quit();

`

All 13 comments

It seems to be a race condition with UnixProcess, because when I step by step with debugguer, it exit properly.

It seems that the timeouts defined for calls to watchdog.waitForTerminationAfterDestroy at UnixProcess.java#L118 and UnixProcess.java#L126 are too low.

When I set them both to 10 SECONDS, it fix the issue.

Same problem here, OS is WIn10, the rest of the meta is the same.

Similar issue on StackOverflow: http://stackoverflow.com/q/39266730/4234729

I have the same issue on: Win10 + selenium 3.0.0-beta3

There is some code that is not cross-platform that I see causing this. thee following section of code will get executed on Windows if a process can't be killed:
https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/os/UnixProcess.java#L131
watchdog.getPID will never work on Windows, so this log statement should probably be skipped or logged without a PID when running on Windows.

Same problem here .
os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_66'
Firefox version : 48.0.2
Selenium : 3.0.0-beta3

So, the exception should be fixed with b3c53bfa3937517dab66fc3ccfe6b0fca33da8b2

But this seems to point to a lingering issue... The process seems to have claimed to be complete (otherwise an exception would have been thrown). And isRunning returned true. This _should not_ be happening.

So, in the meantime this will just log an error message and the process may or may not still be running. I'd be curious to know if it is still running or not if someone can test out the fix.

I think the problem is the plugin-container.exe process that is started by firefox.exe.
firefox
When driver.quit() is called I see
error
and these log entries

[Child 5876] WARNING: pipe error: 232: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 513
[Child 5876] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2052
Oct 03, 2016 11:27:14 AM org.openqa.selenium.os.UnixProcess destroy
SEVERE: Unable to kill process with PID 7836

Both geckodriver.exe and firefox.exe terminate, but plugin-container.exe only terminates after I close the error dialog box.

It looks like this issue.

I tried following and that worked for me!
Environment Details:
OS: Window 8
Firefox version: 51.0.1 (32 bit)
gecko driver: v0.13.0
Selenium: 3.0.1
Java: 1.8

Steps:

  1. Open Firefox manually.
  2. In Url bar, type about:config
  3. Search for autos
  4. set "browser.tabs.remote.autostart.2" value to false.
    (For more details, check https://support.mozilla.org/en-US/questions/1147868
  5. close firefox.
  6. From "Run", type "firefox -p"
  7. Delete any existing profile.
  8. Create new profile and Click "Start firefox"
  9. Close firefox.
  10. Now try executing your Selenium code.
`System.setProperty("webdriver.gecko.driver", "specify path to geckodriver");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();

ProfilesIni profileIni= new ProfilesIni();

FirefoxProfile profile = profileIni.getProfile("default");
capabilities.setCapability("firefox_profile", profile);
WebDriver driver=new FirefoxDriver(capabilities);

driver.get("http://google.com");
....
...
driver.quit();

`

Hi,
has this issue been fixed?
Running on windows and not unix, firefox driver.quit() crashes.
I followed @sameerauto 's note but no luck.

for windows we seem to only wait 1 seconds...but for Linux at worst case 2 + 1 which is three seconds...
If @Toilal comment above is correct then 1 second is not enough for Windows.
@Toilal can I change this on my system without downloading the wholoe source code?

There is no more MarionetteDriver, it has been merged back to FirefoxDriver. If the issue is still actual for the current implementation of FirefoxDriver please raise a new issue.

change

        // Close driver
        driver.quit(); 

To

        driver.navigate().to("about:config");
        driver.navigate().to("about:blank");
        // Close driver
        driver.quit();
Was this page helpful?
0 / 5 - 0 ratings