Driver.Quit() hanging with IEDriverServer.exe

2,837 views
Skip to first unread message

eduardo sousa

unread,
Jul 5, 2012, 11:02:21 AM7/5/12
to seleniu...@googlegroups.com
Hi,
I've recently changed to the IEDriverServer from the dll and I've noticed that the application sometimes started hanging when doing Driver.Quit() and it only seems to resume when I click the windows alert (the one that says "This program has stopped functioning, etc...").

The problem after debugging seems to be with the instruction "this.Execute(DriverCommand.Quit, null);" (RemoteWebDriver.Quit(), line 328 in RemoteWebDriver.cs) which seems to never return. Only when you press the alert it goes in the corresponding WebDriverException catch.

From examining the IEDriverServer logs I can see the following two lines (notice the timestamp differences):

"T 2012-07-05 15:11:38:808 Browser.cpp(242) Entering Browser::DetachEvents
T 2012-07-05 15:19:33:404 server.cc(62) Entering Server::OnHttpEvent"

Which will boil down to three lines in Browser.cpp :

  CComQIPtr<IDispatch> dispatch(this->browser_);
  CComPtr<IUnknown> unknown(dispatch);
  HRESULT hr = this->DispEventUnadvise(unknown);

I'd bet on the last line but I can't be sure as I use the exe directly (the C# webdriver code gets built with my app) so I can't debug this. Could someone help me pretty please? I was quite happy happy with the server logging capabilities and didn't want to go back and use the dll again :(

Can't seem to find any evidence of an event viewer error for this either.

For the record, I'm using the latest selenium build (found in http://selenium.googlecode.com/svn/trunk) with a IE9.0.8112 on a 32bits Windows7. Thanks in advance.

Best Regards,
Eduardo Sousa

eduardo sousa

unread,
Jul 5, 2012, 12:28:12 PM7/5/12
to seleniu...@googlegroups.com
A good workaround for this, instead of using Driver.Quit(), is the following :

                Process[] processes = Process.GetProcessesByName("iexplore");

                foreach (Process process in processes)
                {
                    process.Kill();
                }

                processes = Process.GetProcessesByName("IEDriverServer");

                foreach (Process process in processes)
                {
                    process.Kill();
                }

A bit nasty but it does the trick while we wait for the fix.

Jim Evans

unread,
Jul 5, 2012, 3:04:11 PM7/5/12
to seleniu...@googlegroups.com
Something is crashing the IEDriverServer.exe process. DispEventUnadvise probably isn't the culprit, as all it's doing is unhooking COM events that the IE driver subscribes to, which is usually a pretty safe operation. There are tests in the WebDriver project itself that test the use of driver.Quit() under a number of scenarios. None of these exhibit the crash you're describing. A reproducible test case (as soon as you can provide one) is going to be the way forward here.

--Jim

eduardo sousa

unread,
Jul 6, 2012, 8:37:28 AM7/6/12
to seleniu...@googlegroups.com
Ok, thanks for the reply Jim. I suspected that the problem might not be from the driverserver but I have the feeling that now the server blocks when there's a a race condition. I say this because sometimes crashes after loading a page but before loading a frame and when I dismiss the warning it detaches the server, loads the rest of the page as "This page cannot be displayed" and throws an exception saying "No response from server for url http://localhost:53271/session/e5d009c9-2d82-4abb-8ea4-6155b6f98511/window" . What I'm under the impression is that, with the dll, I would get an exception back and now the webdriver is blocking instead of replying with a StaleElementException as it was before. Does this makes any sense to you? I'm not sure about what I'm saying here, that's why I'm asking.

Also, the problem's quite hard to replicate because it doesn't happen regularly, just under certain conditions which I have no control of (like database access times, etc).

Anyway, thanks for the attention.

Best Regards,
Eduardo Sousa

prem kumar

unread,
Jul 6, 2012, 9:59:11 AM7/6/12
to seleniu...@googlegroups.com
Hi Eduardo ,
 I have tried your code to kill process but I am getting the error in code itself.. Can you please send me the full code to do the same..
Regards,
Kumar

eduardo sousa

unread,
Jul 6, 2012, 10:59:47 AM7/6/12
to seleniu...@googlegroups.com
Hi Kumar,
that was the full code. I wouldn't recommend for you to use it as you should exit webdriver using driver.Quit(). I've just used it as a quick workaround because my webapp was hanging. If it's not working for you it might be because you have different processes running. To see that I'd recommend Process Explorer from SysInternals but from my screenshot you can see my VS2008 spawns, amongst other things, an IEDriver process that itself creates browser windows as child processes. You just need to find out the names of your processes and start killing them, starting from the father and finishing in the children. Hope this helped.

Best Regards,
Eduardo Sousa

Jim Evans

unread,
Jul 6, 2012, 2:28:04 PM7/6/12
to seleniu...@googlegroups.com
Here's the dirty little secret about the IEDriverServer.exe: it uses the *exact* same code as the .dll version. I'd need to see the problem in action to be able to debug it further.
Message has been deleted

ALISTER ERNEST

unread,
Oct 11, 2012, 1:54:46 PM10/11/12
to seleniu...@googlegroups.com, eduardo...@gmail.com
Guys,

This may not be an accurate solution but for me, with IE 9 (32 & 64bit) IEDriverServer - using the "driver.close()" works without issues.
I was seeing the same errors when using the "driver.quit()".

Hope this helps.

-Alister

On Sunday, September 30, 2012 9:50:40 PM UTC-6, adw...@hotmail.com wrote:
I can reproduce this issue every time now, and I have digged out more info, however I have not figure out why yet. Here is what I have found:
 
T 2012-10-01 11:13:20:921 server.cc(179) Entering Server::ShutDownSession
T 2012-10-01 11:13:20:921 IESession.cpp(64) Entering IESession::ShutDown
** WM_CLOSE send to IE_CommandExecutor
 
T 2012-10-01 11:13:20:932 IECommandExecutor.cpp(147) Entering IECommandExecutor::OnClose
T 2012-10-01 11:13:20:932 IECommandExecutor.cpp(159) Entering IECommandExecutor::OnDestroy
T 2012-10-01 11:13:20:932 IECommandExecutor.cpp(162) Leaving IECommandExecutor::OnDestroy
T 2012-10-01 11:13:20:932 IECommandExecutor.cpp(151) Leaving IECommandExecutor::OnClose
T 2012-10-01 11:13:20:980 Browser.cpp(28) Entering Browser::~Browser
T 2012-10-01 11:13:20:981 Browser.cpp(244) Entering Browser::DetachEvents
T 2012-10-01 11:13:20:981 Browser.cpp(249) Leaving Browser::DetachEvents
T 2012-10-01 11:13:20:981 Browser.cpp(30) Leaving Browser::~Browser
** IECommandExecutore and Browser will shut down nicely
** IESession is still waiting here
    DWORD wait_result = ::WaitForSingleObject(thread_handle, 30000);
and then crash happens, it seems that the crash happens during the process of closing process of IECommandExecutor or Browser. I think this may related to this line of code in IESession.cpp: 
  // Kill the background thread first - otherwise the IE process crashes.
  stopPersistentEventFiring();
 
  I will when something happens(like in my example, an confirm dialog pops up when the window unload), this stopPersisentEventFiring may fail, then the close may crose IE process.
 
  Just my theory for now, I will try to dig out ,more.
 
Adam

在 2012年7月5日星期四UTC+8下午11时02分21秒,eduardo sousa写道:
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Jim Evans

unread,
Oct 22, 2012, 11:02:29 AM10/22/12
to seleniu...@googlegroups.com, eduardo...@gmail.com
I have checked in what I believe is a fix[1] for the specific reproducible case mentioned here, with an onbeforeunload dialog and with focus on a frame. As such, I've marked the issue[2] as closed, since the existing issue is far too vague to be completely certain that every single crash in the executable has been handled. If, after picking up the fix[3], you are still seeing crashes in IEDriverServer.exe, please open a new issue.

Also, please note that from this point forward, issues that say "IEDriverServer.exe crashes" without reproducible code (including either an HTML page or a public URL to reproduce against) will be closed without action. I realize this may seem overly draconian, but issue reports that simply say, "it crashes," are far too vague to be actionable. Likewise, issue reports that do not include HTML to reproduce against do not provide an appropriate level of information to fix the issue, as the same WebDriver code running against a different page can, and even is likely to, produce different results.

--Jim

[1] http://code.google.com/p/selenium/source/detail?r=17990
[2] http://code.google.com/p/selenium/issues/detail?id=4178
[3] http://selenium.googlecode.com/svn/trunk/cpp/prebuilt/Win32/Release

On Sunday, October 21, 2012 9:16:17 AM UTC-4, adw...@hotmail.com wrote:
give the culprit is the deconstructing process of focused_frame_window_, I tried to work around this issue by using Unselect Frame in Robot Framework+Selenium2Lib, which basically calling switch_to_default_content(). This prevent the crash in my machine, others may give a try.

在 2012年7月5日星期四UTC+8下午11时02分21秒,eduardo sousa写道:
Reply all
Reply to author
Forward
0 new messages