Search code examples
javascriptwatin

Run JavaScript in WatiN is failed


I'm trying to clicking on span element (usual click() does not work) by FireEvent() method:

IE.Span(Find.ById("ueiwo-r")).FireEvent("onmouseclick");

But I get an error:

Exception: RunScriptException, RunScript failed Inner: Exception from HRESULT: 0x80020101

Does anybody know how to workaround this problem?

Here is html snippet:

<td class="urMnuTxt">
<span style="white-space: nowrap;">Add New Item

I have Win7, IE8 and WatiN 2.0


Solution

  • I found the solution: before clicking I put FireEvent("onmousemove") then click with the following code:

    IE.Span(Find.ById("ueiwo-r")).FireEvent("onmousemouve");
    IE.Span(Find.ById("ueiwo-r")).click();
    

    That works for me.