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

javascript error when handling dropdowns

3 Answers 83 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vrushali
Top achievements
Rank 1
Vrushali asked on 11 Jan 2017, 03:09 PM

Hi,

document.getElementsByTagName('select')[6];target.dispatchEvent(evt);] failed! Please make sure the function exists and the call is using the correc

I updated test studio version yesterday and then started seeing this error in all places where drop down is when tests are ran.

 

Below is the error --

 

ExecuteCommand failed!InError set by the client. Client Error:System.InvalidOperationException: Javascript call [var eventObjJSON = 'null';var eventObj = JSON.parse(eventObjJSON);var eventType = "HTMLEvents";var eventName = "change";var evt = document.createEvent(eventType);if (!evt) throw "Error creating event";var altKey = false;var ctrlKey = false;var shiftKey = false;var metaKey = false;if (eventType == "HTMLEvents" || !eventObj) {evt.initEvent(eventName, true, true);}else {if (eventObj.modifiers & 0x01)altKey = true;if (eventObj.modifiers & 0x02)ctrlKey = true;if (eventObj.modifiers & 0x04)shiftKey = true;if (eventObj.modifiers & 0x08)metaKey = true;if (eventType == "MouseEvents") {var button = 0;if (eventObj.button & 1)button = 0;else if (eventObj.button & 2)button = 2;else if (eventObj.button & 4)button = 1;var relatedTarget;if (eventObj.relatedTarget)relatedTarget = eval(eventObj.relatedTarget);evt.initMouseEvent(eventName, true, true, window, 0, eventObj.screenX, eventObj.screenY,0, 0, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);}else if (eventType == "KeyboardEvent") {var keyCode;var charCode;keyCode = eventObj.keyCode;if (eventName == "keypress") {charCode = eventObj.keyCode;}else {charCode = 0;}var keyNum = String.fromCharCode(parseInt(keyCode)).toUpperCase().charCodeAt(0);var keyIdentifier = "U+00" + keyNum.toString(16);evt.initKeyboardEvent(true, true, window,keyIdentifier,0, ctrlKey, altKey, shiftKey, metaKey);}}var target = document.getElementsByTagName('select')[6];target.dispatchEvent(evt);] failed! Please make sure the function exists and the call is using the correct prototype signature. Javascript error: [object Error] at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJson, IHTMLDocument2 doc) at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeEvent(IHTMLElement target, BrowserCommand command) at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request) at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommandInternal(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)BrowserCommand (Type:'Action',Info:'NotSet',Action:'InvokeEvent',Target:'ElementId (tagName: 'select',occurrenceIndex: '6')',Data:'onchange--@@--null',ClientId:'Client_c62ec753-e4e2-4ff5-af77-8fe0c44bee21',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'2',InError:'True',Response:'System.InvalidOperationException: Javascript call [var eventObjJSON = 'null';var eventObj = JSON.parse(eventObjJSON);var eventType = "HTMLEvents";var eventName = "change";var evt = document.createEvent(eventType);if (!evt) throw "Error creating event";var altKey = false;var ctrlKey = false;var shiftKey = false;var metaKey = false;if (eventType == "HTMLEvents" || !eventObj) {evt.initEvent(eventName, true, true);}else {if (eventObj.modifiers & 0x01)altKey = true;if (eventObj.modifiers & 0x02)ctrlKey = true;if (eventObj.modifiers & 0x04)shiftKey = true;if (eventObj.modifiers & 0x08)metaKey = true;if (eventType == "MouseEvents") {var button = 0;if (eventObj.button & 1)button = 0;else if (eventObj.button & 2)button = 2;else if (eventObj.button & 4)button = 1;var relatedTarget;if (eventObj.relatedTarget)relatedTarget = eval(eventObj.relatedTarget);evt.initMouseEvent(eventName, true, true, window, 0, eventObj.screenX, eventObj.screenY,0, 0, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);}else if (eventType == "KeyboardEvent") {var keyCode;var charCode;keyCode = eventObj.keyCode;if (eventName == "keypress") {charCode = eventObj.keyCode;}else {charCode = 0;}var keyNum = String.fromCharCode(parseInt(keyCode)).toUpperCase().charCodeAt(0);var keyIdentifier = "U+00" + keyNum.toString(16);evt.initKeyboardEvent(true, true, window,keyIdentifier,0, ctrlKey, altKey, shiftKey, metaKey);}}var target = document.getElementsByTagName('select')[6];target.dispatchEvent(evt);] failed! Please make sure the function exists and the call is using the correct prototype signature. Javascript error: [object Error] at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJson, IHTMLDocument2 doc) at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeEvent(IHTMLElement target, BrowserCommand command) at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request) at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommandInternal(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')InnerException: none.InnerException:ArtOfTest.WebAii.Exceptions.ExecuteCommandException: ExecuteCommand failed!InError set by the client. Client Error:System.InvalidOperationException: Javascript call [var eventObjJSON = 'null';var eventObj = JSON.parse(eventObjJSON);var eventType = "HTMLEvents";var eventName = "change";var evt = document.createEvent(eventType);if (!evt) throw "Error creating event";var altKey = false;var ctrlKey = false;var shiftKey = false;var metaKey = false;if (eventType == "HTMLEvents" || !eventObj) {evt.initEvent(eventName, true, true);}else {if (eventObj.modifiers & 0x01)altKey = true;if (eventObj.modifiers & 0x02)ctrlKey = true;if (eventObj.modifiers & 0x04)shiftKey = true;if (eventObj.modifiers & 0x08)metaKey = true;if (eventType == "MouseEvents") {var button = 0;if (eventObj.button & 1)button = 0;else if (eventObj.button & 2)button = 2;else if (eventObj.button & 4)button = 1;var relatedTarget;if (eventObj.relatedTarget)relatedTarget = eval(eventObj.relatedTarget);evt.initMouseEvent(eventName, true, true, window, 0, eventObj.screenX, eventObj.screenY,0, 0, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);}else if (eventType == "KeyboardEvent") {var keyCode;var charCode;keyCode = eventObj.keyCode;if (eventName == "keypress") {charCode = eventObj.keyCode;}else {charCode = 0;}var keyNum = String.fromCharCode(parseInt(keyCode)).toUpperCase().charCodeAt(0);var keyIdentifier = "U+00" + keyNum.toString(16);evt.initKeyboardEvent(true, true, window,keyIdentifier,0, ctrlKey, altKey, shiftKey, metaKey);}}var target = document.getElementsByTagName('select')[6];target.dispatchEvent(evt);] failed! Please make sure the function exists and the call is using the correct prototype signature. Javascript error: [object Error] at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJson, IHTMLDocument2 doc) at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeEvent(IHTMLElement target, BrowserCommand command) at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request) at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommandInternal(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)BrowserCommand (Type:'Action',Info:'NotSet',Action:'InvokeEvent',Target:'ElementId (tagName: 'select',occurrenceIndex: '6')',Data:'onchange--@@--null',ClientId:'Client_c62ec753-e4e2-4ff5-af77-8fe0c44bee21',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'2',InError:'True',Response:'System.InvalidOperationException: Javascript call [var eventObjJSON = 'null';var eventObj = JSON.parse(eventObjJSON);var eventType = "HTMLEvents";var eventName = "change";var evt = document.createEvent(eventType);if (!evt) throw "Error creating event";var altKey = false;var ctrlKey = false;var shiftKey = false;var metaKey = false;if (eventType == "HTMLEvents" || !eventObj) {evt.initEvent(eventName, true, true);}else {if (eventObj.modifiers & 0x01)altKey = true;if (eventObj.modifiers & 0x02)ctrlKey = true;if (eventObj.modifiers & 0x04)shiftKey = true;if (eventObj.modifiers & 0x08)metaKey = true;if (eventType == "MouseEvents") {var button = 0;if (eventObj.button & 1)button = 0;else if (eventObj.button & 2)button = 2;else if (eventObj.button & 4)button = 1;var relatedTarget;if (eventObj.relatedTarget)relatedTarget = eval(eventObj.relatedTarget);evt.initMouseEvent(eventName, true, true, window, 0, eventObj.screenX, eventObj.screenY,0, 0, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);}else if (eventType == "KeyboardEvent") {var keyCode;var charCode;keyCode = eventObj.keyCode;if (eventName == "keypress") {charCode = eventObj.keyCode;}else {charCode = 0;}var keyNum = String.fromCharCode(parseInt(keyCode)).toUpperCase().charCodeAt(0);var keyIdentifier = "U+00" + keyNum.toString(16);evt.initKeyboardEvent(true, true, window,keyIdentifier,0, ctrlKey, altKey, shiftKey, metaKey);}}var target = document.getElementsByTagName('select')[6];target.dispatchEvent(evt);] failed! Please make sure the function exists and the call is using the correct prototype signature. Javascript error: [object Error] at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJson, IHTMLDocument2 doc) at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeEvent(IHTMLElement target, BrowserCommand command) at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request) at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommandInternal(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')InnerException: none. at ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand request) at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady) at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request) at ArtOfTest.WebAii.Core.Actions.InvokeEvent(Element targetElement, ScriptEventType eventType) at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.InvokeEvent(ScriptEventType eventType) at ArtOfTest.WebAii.Controls.HtmlControls.HtmlSelect.InvokeOnChange(Boolean initEvent) at ArtOfTest.WebAii.Design.IntrinsicTranslators.Descriptors.SelectDropDownActionDescriptor.Execute(Browser browser) at ArtOfTest.WebAii.Design.Extensibility.HtmlActionDescriptor.Execute(IAutomationHost autoHost) at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteStep(Int32 order)

 

 

3 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 16 Jan 2017, 11:31 AM
Hi Vrushali,

I guess the previous version of Test Studio you used was not a recent one and the error you shared is most probably related to execution against IE. Please note to upgrade your IE browser to the latest version - 11.

Additionally it is important to double check how the application is built to act when running in IE. This could be double checked when running the application in IE and type in the console in Developers Mode "document.documentMode". If the application is acting like against a lower version of IE than 11 you could face that issue. 

Another clue that the tested application might behave as in a lower IE version is a tag similar to this one: 

<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE"/>

I hope any of the above advice will be applicable in your case as well. Thanks! 

Regards,
Elena Tsvetkova
Telerik by Progress
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Madhu
Top achievements
Rank 1
answered on 09 Feb 2018, 10:37 PM

Hi Vrushali,

 

I have the same issue with new Telerik version (2018.1.130.0), all dropdown verifications/selections are failing. What steps did you follow to overcome these issues? Any help from you would be appreciated.

 

Thanks,

Madhu

0
Elena
Telerik team
answered on 14 Feb 2018, 02:35 PM
Hello Vrushali,

Thank you for reaching us out. 

Since you are referring a post which dates back an year ago I would like to kindly ask you to share further details on your exact issue as this might be quite different. 

Please let me know which is the browser used for execution? Have you tried to insert execution delay before the step to select from dropdown and if yes what the outcome was? Is it possible to provide a sample test which reproduces the same behavior? 

In general the issue discussed here was caused by the fact the application under test was either built to change the compatible mode of the IE browser and make it act as any previous version or the IE browser was not up-to-date. 

I hope the abpve will be helpful to you. 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Vrushali
Top achievements
Rank 1
Answers by
Elena
Telerik team
Madhu
Top achievements
Rank 1
Share this question
or