WatiN Dispose() 真的很慢
当我处理 Internet Explorer 对象时,我的 WatiN 测试突然变得非常慢。
这是我的设置...
* Windows 7 (Evaluation Build 7100)
* Internet Explorer 8 (Version 8.0.7100.0)
* WatiN (Version 2.0.10.928)
这很奇怪,因为大约一周前测试运行良好。 我认为这是最新的微软更新或其他什么。
有任何想法吗?
My WatiN tests have suddenly gotten REALLY slow when I dispose the Internet Explorer object.
Here's my setup...
* Windows 7 (Evaluation Build 7100)
* Internet Explorer 8 (Version 8.0.7100.0)
* WatiN (Version 2.0.10.928)
This is strange because the tests were working fine a week or so ago. I think it's the latest MS Updates or something.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了 IE 缓慢关闭(或从不关闭)的问题,但在执行以下操作后,我遇到了零问题:
链接,我使用由以下描述的 BrowserStaticInstanceHelper 版本
Jeroen van Menen,Watin 英雄,此处。 它提供了一种归零和
附加到特定的浏览器窗口。
最后一个问题:
由于我有多个 TestMethods 和 TestClasses,我想将 IE.Close() 放入 AssemblyCleanup() 方法中。 由于 MSTest 线程问题,我必须像这样调用 close():
*再次,此代码片段中的 IE 指的是一个属性,该属性将使用上面链接中的策略检查并附加到我的 IE 实例。 如果没有我链接到的模式的其余部分,此代码片段可能无法解决您的问题。
在此设置之前,IE 有时需要 30 秒以上才能关闭,现在我可以在测试运行时打开和关闭其他 IE 窗口,并且浏览器始终可靠地关闭。
I was having issues with IE closing slowly (or never), but after doing the following I've had zero issues:
links, I use a version of the BrowserStaticInstanceHelper described by
Jeroen van Menen, Watin hero, here. It provides a way to zero in and
attach to a specific browser window.
One last issue:
Since I have multiple TestMethods and TestClasses, I wanted to put IE.Close() in an AssemblyCleanup() method. Due to MSTest threading issues, I then had to call close() like this:
*Again, IE in this snippet refers to a property that will check for and attach to my IE instance using the strategy from the link above. This snippet probably won't solve your problems without the rest of the pattern that I linked to.
Before this setup IE would sometimes take 30+ seconds to close, now I can open and close other IE windows all I want while the tests are running, and the browser always closes reliably.
您需要做的是将运行测试的线程设置为 STA 模式,IE 将快速关闭。
对于那些不是做过 COM 编程的老手来说,这描述了 STA http://msdn.microsoft.com/en-us/library/windows/desktop/ms680112(v=vs.85).aspx。 简而言之,STA 是 COM 使用的一种老式技术,用于保留 Windows 95 时代遗留下来的现有的、经过测试的、可工作的单线程代码在可怕的、新奇的抢占式多线程世界中的可行性。
现在,CLR 位于 COM 所称的 MTA 中。 对于我们这些没有生活在 1998 年的人来说,您可以将 MTA 视为现实世界,那里的一切都按其应有的方式运行。 http://msdn.microsoft。 com/en-us/library/windows/desktop/ms693421(v=vs.85).aspx
当超级可怕的 MTA 中的某个线程想要访问 STA 中的某些内容时,MTA 线程被告知坐下如果 STA 当前正由与 MTA 不同的线程访问,则在工作台上等待轮到它。 这基本上意味着,有时,当天气不合适时,您可能会出现这些奇怪的滞后现象。
What you need to do is set the thread the test is running on into STA mode, and IE will close quickly.
For those of you who aren't old farts who have done COM programming, this describes an STA http://msdn.microsoft.com/en-us/library/windows/desktop/ms680112(v=vs.85).aspx. Short story, STA is an old-school technique used by COM to preserve the viability of existing, tested, working, single-threaded code left over from the Windows 95 days in the scary, new-fangled world of preemptive multithreading.
Now, the CLR lives in what the COM calls the MTA. For those of us that don't live in 1998, you can think of the MTA as the real world, where things work the way they should. http://msdn.microsoft.com/en-us/library/windows/desktop/ms693421(v=vs.85).aspx
When some thread in the super-scary MTA wants to access something in an STA, the MTA thread is told to sit on the bench and wait its turn if the STA is currently being accessed by a different thread from the MTA. This basically means that sometimes, when the weather isn't right, you can get these wierd-o lags.
我在使用 IE9 时也遇到过同样的间歇性问题。 我两边的同事都没有同样的问题。 我们刚刚意识到我的默认浏览器是 IE,我倾向于打开它并运行多个选项卡。
当我的 WatIn 测试运行时,我一直在桌面上没有打开 IE 的情况下工作,自从采用这种做法以来,我没有遇到过问题。
可能是巧合,也可能是答案?!
I've been having the same, intermittent problem with IE9. My colleagues either side of me do not have the same issues. We have just realised that my default browser is IE and I tend to have it open with several tabs running.
I've been working with no IE open on the desktop while my WatIn tests run and I haven't had the problem since I adopted this practice.
Possibly coincidence, or possibly the answer?!