onSubmit event doesn't invoke

3 posts, 0 answers
  1. Oleg
    Oleg avatar
    7 posts
    Member since:
    Jan 2011

    Posted 20 Jan 2011 Link to this post

    Hello. I've faced with the situation when onChange event doesn't invoke. I have next element:
    <input id="txtName" type="text" style="width: 300px;" onchange="txtNameChanged();" id="txtName" maxlength="50" value="Test" name="txtName">

    I put the value into this input element using TxtName.Text = "TestValue". Everything is OK. But after the value was inputted the method onchange="txtNameChanged(); should be invoked. It doesn't happens automatically.
    I tried to use InvokeEvent(ScriptEventType.OnChange); after TxtName.Text = "TestValue";  but nothing happens. Method onChange still wasn't invoked. Also I tried ActiveBrowser.Actions.InvokeScript("txtNameChanged();"); but it generates me exceptions

    Test method Creation threw exception:  ArtOfTest.WebAii.Exceptions.ExecuteCommandException: ExecuteCommand failed!
    InError set by the client. Client Error:
    System.InvalidOperationException: Javascript call [txtNameChanged();] failed! Please make the function exists and the call is using the correct prototype signature. Javascript error: TypeError: Object expected
       at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJSON)
       at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
       at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request,

    Could you please help me with onChange event. How can I type the text into the input and invoke method txtNameChanged(); ????
  2. Oleg
    Oleg avatar
    7 posts
    Member since:
    Jan 2011

    Posted 25 Jan 2011 Link to this post

    Could anybody help?
  3. Stoich
    Stoich avatar
    1 posts

    Posted 25 Jan 2011 Link to this post

    Hi Oleg,
        my hunch is you need to lose the focus on the input element in order to Fire the onChange event. There are many ways to switch the focus inside a browser instance. The easiest way is probably to record a Tab click. Since you seem to be using the WebAii Framework and not WebUI Test Studio itself, here the code that will let you do that:
    ActiveBrowser.Manager.Desktop.KeyBoard.KeyPress(ArtOfTest.WebAii.Win32.KeyBoard.KeysFromString("Tab"), 150, 1);
    Try adding this line after TxtName.Text = "TestValue".

    Let me know how it goes!

    All the best,
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Back to Top