This is a migrated thread and some comments may be shown as answers.

onSubmit event doesn't invoke

2 Answers 79 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Oleg
Top achievements
Rank 1
Oleg asked on 20 Jan 2011, 03:01 PM
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 Answers, 1 is accepted

Sort by
0
Oleg
Top achievements
Rank 1
answered on 25 Jan 2011, 02:00 PM
Could anybody help?
0
Stoich
Telerik team
answered on 25 Jan 2011, 05:29 PM
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,
Stoich
the Telerik team
Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Tags
General Discussions
Asked by
Oleg
Top achievements
Rank 1
Answers by
Oleg
Top achievements
Rank 1
Stoich
Telerik team
Share this question
or