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

Firefox: Actions.InvokeScript<T> error, works fine in IE/Chrome

2 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Connections Academy Developer
Top achievements
Rank 1
Connections Academy Developer asked on 06 Jun 2013, 07:19 PM
Consider the following tests:

const string JS = "( function() { var ls = []; for(var i = 0; i < 10; i++) ls.push({ Key: \"key_\" + i, Value: \"value_\" + i }); return ls; } )();";
 
[TestMethod]
public void testJavascriptReturnsDictionaryIe() {
    Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
    var result = Actions.InvokeScript<Dictionary<string, string>>(JS);
}
 
[TestMethod]
public void testJavascriptReturnsDictionaryFirefox() {
    Manager.LaunchNewBrowser(BrowserType.FireFox);
    var result = Actions.InvokeScript<Dictionary<string, string>>(JS);
}
 
[TestMethod]
public void testJavascriptReturnsDictionaryChrome() {
    Manager.LaunchNewBrowser(BrowserType.Chrome);
    var result = Actions.InvokeScript<Dictionary<string, string>>(JS);
}

Chrome and IE return a Dictionary<string,string> properly. Firefox (I have version 21, with Firefox Http Client 2012.2.1205.0) throws an exception during InvokeScript:
Test method namespaced.TelerikTest.testJavascriptReturnsDictionaryFirefox threw exception:
System.Runtime.Serialization.SerializationException: The data contract type 'System.Runtime.Serialization.KeyValue`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' cannot be deserialized because the required data members 'Key, Value' were not found.
    at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ThrowMissingRequiredMembers(Object obj, XmlDictionaryString[] memberNames, Byte[] expectedElements, Byte[] requiredElements)
   at ReadKeyValueOfstringstringFromJson(XmlReaderDelegator, XmlObjectSerializerReadContextComplexJson, XmlDictionaryString, XmlDictionaryString[])
   at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadJsonValue(DataContract contract, XmlReaderDelegator reader, XmlObjectSerializerReadContextComplexJson context)
   at ReadArrayOfKeyValueOfstringstringFromJson(XmlReaderDelegator, XmlObjectSerializerReadContextComplexJson, XmlDictionaryString, XmlDictionaryString, CollectionDataContract)
   at System.Runtime.Serialization.Json.JsonCollectionDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadJsonValue(DataContract contract, XmlReaderDelegator reader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, ref DataContract dataContract)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
   at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
   at ArtOfTest.WebAii.Core.Actions.InvokeScript(String script)
   at namespaced.TelerikTest.testJavascriptReturnsDictionaryFirefox() in telerikTest.cs: line 139


Any help or resolution is appreciated. I'm trying not to need separate Javascript for each browser, because Testing Framework should abstract that for me. Thank you.

2 Answers, 1 is accepted

Sort by
0
Accepted
Cody
Telerik team
answered on 11 Jun 2013, 06:08 PM
Hi,

I see what you mean. I don't have a solution to this. I've filed a bug report on this problem. Our software development team will take a look and see what they can do.

Regards,
Cody
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Connections Academy Developer
Top achievements
Rank 1
answered on 13 Jun 2013, 09:14 PM
Thank you. We'll follow the bug report.
Tags
General Discussions
Asked by
Connections Academy Developer
Top achievements
Rank 1
Answers by
Cody
Telerik team
Connections Academy Developer
Top achievements
Rank 1
Share this question
or