When testing with WatiN: “'DebuggerDisplayProxy()' threw an exception of type 'System.InvalidCastException'”

别说谁变了你拦得住时间么 提交于 2020-01-05 05:29:15

问题


FrameworkActionsLink = CurrentBuyerSite.BuyerWorkAreaFrame.Link(Find.ById("actions"));

I have code which finds a link element by finding by ID.

The HTML on the page is:

<a id="actions" href="Javascript:ShowMenuItem('options','actions'); ... >

I have excluded the full Javascript code in the href where you see "...".

On test execution, sometimes this code works correctly, but sometimes I get the following error:

'DebuggerDisplayProxy()' threw an exception of type 'System.InvalidCastException'

It's a pretty straightforward bit of code, I just wondered if anyone had experienced similar problems or error messages. Do you think this is an issue with the WatiN tool, the web application, the internet browser, or perhaps something else entirely?


回答1:


Can you try the following code:

FrameworkActionsLink = (WatiN.Core.Link)CurrentBuyerSite.BuyerWorkAreaFrame.Link(Find.ById("actions"));

I'm pretty sure that it doesn't like the link being JavaScript:...

Edit: Try maybe this:

CurrentBuyerSite.Eval("ShowMenuItem('options','actions'); ...");



回答2:


What runner are you using? if nUnit 64bit then try 32bit or other runner.

Maybe the issue is that page didn't fully download and that makes problem with javascript function, try replace Click() for ClickNoWait().



来源:https://stackoverflow.com/questions/11153205/when-testing-with-watin-debuggerdisplayproxy-threw-an-exception-of-type-s

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!