在 Watin 新版本 2.1 中访问框架时出错
在新版本的 Watin 2.1 中访问 ie.Frames
时抛出以下错误错误
详细信息:无法使用与其底层 RCW 分离的 COM 对象。
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease)
at mshtml.HTMLFrameElementClass.IHTMLElement_get_tagName()
at WatiN.Core.Native.InternetExplorer.IEElement.get_TagName()
at WatiN.Core.ElementTag.FromNativeElement(INativeElement nativeElement)
at WatiN.Core.StaticElementFinder.CreateTagList(INativeElement nativeElement)
at WatiN.Core.StaticElementFinder..ctor(DomContainer domcontainer, INativeElement nativeElement)
at WatiN.Core.Element.InitElement(DomContainer domContainer, INativeElement nativeElement, ElementFinder elementFinder)
at WatiN.Core.Element..ctor(DomContainer domContainer, INativeElement nativeElement)
at WatiN.Core.Frame..ctor(DomContainer domContainer, INativeDocument frameDocument)
at WatiN.Core.FrameCollection..ctor(DomContainer domContainer, INativeDocument htmlDocument)
at WatiN.Core.Document.get_Frames()
请帮助我解决这个问题。
Below error is thrown when accessing the ie.Frames
in new version of Watin 2.1
Error details: COM object that has been separated from its underlying RCW cannot be used.
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease)
at mshtml.HTMLFrameElementClass.IHTMLElement_get_tagName()
at WatiN.Core.Native.InternetExplorer.IEElement.get_TagName()
at WatiN.Core.ElementTag.FromNativeElement(INativeElement nativeElement)
at WatiN.Core.StaticElementFinder.CreateTagList(INativeElement nativeElement)
at WatiN.Core.StaticElementFinder..ctor(DomContainer domcontainer, INativeElement nativeElement)
at WatiN.Core.Element.InitElement(DomContainer domContainer, INativeElement nativeElement, ElementFinder elementFinder)
at WatiN.Core.Element..ctor(DomContainer domContainer, INativeElement nativeElement)
at WatiN.Core.Frame..ctor(DomContainer domContainer, INativeDocument frameDocument)
at WatiN.Core.FrameCollection..ctor(DomContainer domContainer, INativeDocument htmlDocument)
at WatiN.Core.Document.get_Frames()
Please help me out it in solving this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我使用 Praveen 的建议修改了 AllFramesProcessor 的代码(见下文)。
在执行此操作之前,我对 Watin 主干进行了 SVN 更新。 Jeroen 于 2011 年 4 月 18 日进行了签入,解决了围绕 WaitForFramesToComplete 重试/等待加载主文档的问题。仅 Jeroen 的修复并没有解决问题,但我相信正是该代码和修改后的 AllFramesProcessor 的组合使 Watin 在框架问题上更加稳定。
I modified the code for AllFramesProcessor using Praveen's suggestion (see below).
Before I did this, I did an SVN update on the Watin trunk. Jeroen made a checkin on 4/18/11 that fixed an issue around WaitForFramesToComplete to retry/wait loading the main document. Jeroen's fix alone didn't solve the problem, but I believe it's the combination of that code and the modified AllFramesProcessor that made Watin more stable around the Frames issue.
您可以通过访问
ie.NativeDocument.Frames
,然后将ie
和任何INativeElement
对象传递给WatiN.Core 来解决此问题。元素构造函数:
You can work around this by accessing
ie.NativeDocument.Frames
and then passingie
and anyINativeElement
objects to theWatiN.Core.Element
constructor:来自 https://sourceforge.net/tracker/?func=detail&aid=3290877&group_id=167632&atid=843727
这个问题似乎是由 AllFramesProcessor 类引起的。这
Watin 1.3 中此类的构造函数如下所示:
2.1 中的构造函数如下所示:
通过将
"htmlDocument.all.tags("iframe")"
更改为"htmlDocument.all.tags("frame")"
根据 Watin 1.3 构造函数似乎可以解决这个问题。不太清楚为什么构造函数被改变
只是寻找 iFrame。
from https://sourceforge.net/tracker/?func=detail&aid=3290877&group_id=167632&atid=843727
This problem seems to be caused by the AllFramesProcessor class. The
constructor for this class in Watin 1.3 looked like this:
The constructor in 2.1 looks like this:
By changing the
"htmlDocument.all.tags("iframe")"
to be"htmlDocument.all.tags("frame")"
as per the Watin 1.3 constructor thisseems to resolve this issue. Not quite sure why the constructor was changed
to just look for iFrames though.
最近我也遇到了这个问题,我首先遵循 Richard Guions(已接受)的答案,只是为了详细说明我做了以下操作:-
然后加载“Watin/trunk/src/WatiN.sln”解决方案并重新编译src,然后在我的项目中引用新的 Watin.core.dll。
瞧,
browser.Frame(Find.ByName("maincontent"));
开始工作,我不需要对 AllFrames 代码应用任何其他更改。所以我认为 svn 源已经更新以包含此更改Recently I also encountered this problem and I started by following Richard Guions (accepted) answer and just to elaborate a little on that I did the following:-
and then loaded the "Watin/trunk/src/WatiN.sln" solution and recompiled the src, then referencing that new Watin.core.dll in my project.
Low and behold the
browser.Frame(Find.ByName("maincontent"));
started working and I did not need to apply any other changes to the AllFrames code. So I think that the svn source has already been updated to include this change