Error on invoke script event command

3 posts, 0 answers
  1. Phuong
    Phuong avatar
    6 posts
    Member since:
    Dec 2010

    Posted 27 Jul 2011 Link to this post

    Hi,

    I have the test steps below:
    -click “Add” link
    - a pop-up window displays
    -select some data on pop-up
    -click “OK” link to close pop-up, then the data on pop-up will be reflected on main window

    Currently my application under test behavior is after clicking “OK” link, a JavaScript is called to load the data in the pop-up to main window.  In my test script, I used lnkOK.Click() command to stimulate the mouse click action but the JavaScript is not called (the data is not added from the pop-up to the main window). Therefore, I used the invoke script event to call the script as below:

    <a id="ctl00_contentPlaceHolderMain_ctrlModifyView_lbtOK" class="lnkStyle" href="javascript:__doPostBack('ctl00$contentPlaceHolderMain$ctrlModifyView$lbtOK','')" onmouseout="ChangeBackgroundColorToYellow(this);" onmouseover="ChangeBackgroundColorToSilver(this);" title="OK" style="background-color: rgb(255, 255, 221);">OK</a>

    lnkOK.Click()
    lnkOK.InvokeEvent(ArtOfTest.WebAii.Core.ScriptEventType.OnClick)

    By using the invoke script command, I get the data loading success. However, sometimes the execution test script occur error:

    Error  :ExecuteCommand failed!
    InError set by the client. Client Error:
    System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
       at mshtml.HTMLAnchorElementClass.IHTMLElement3_FireEvent(String bstrEventName, Object& pvarEventObject)
       at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeEvent(IHTMLElement target, String data)
       at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
       at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)
    BrowserCommand (Type:'Action',Info:'NotSet',Action:'InvokeEvent',Target:'ElementId (tagName: 'a',occurrenceIndex: '145')',Data:'onclick--@@--null',ClientId:'Client_b7dba0e7-48ea-4764-8958-b9e768c23add',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
       at mshtml.HTMLAnchorElementClass.IHTMLElement3_FireEvent(String bstrEventName, Object& pvarEventObject)
       at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeEvent(IHTMLElement target, String data)
       at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
       at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')
    InnerException: none.

    How can I fix this problem?

    Thanks in advance
  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 02 Aug 2011 Link to this post

    Hi Phuong,

    The lnkOK.Click() call also internally calls InvokeEvent. Thus manually calling InvokeEvent afterwards is actually redundant. What is probably happening is when you call InvokeEvent the browser is still busy processing the first event.

    To overcome this I recommend using a Mouse Desktop click instead like this:

    Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, lnkOK.GetRectangle());


    This replaces your lnkOK.Click() call along with anything else you are trying to do to make the OnClick event fire. You will see the mouse actually move and click on the link.

    Best wishes,
    Cody
    the Telerik team
    Check out the Test Studio roadmap to find out more about the new performance testing functionality coming in our R2 2011 release this September!

    Have you looked at the new Online User Guide for Telerik Test Studio?
  3. Phuong
    Phuong avatar
    6 posts
    Member since:
    Dec 2010

    Posted 09 Aug 2011 Link to this post

    Hi Cody,

    Thanks for your help. I tried to apply your instruction in our three first test scripts and it worked well. In this week, I'm going to try on next some test scripts and hope that it also works well.

    Thanks again.
    Phuong
Back to Top