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

3 posts, 1 answers
  1. Connections Academy Developer
    Connections Academy Developer avatar
    63 posts
    Member since:
    May 2005

    Posted 06 Jun 2013 Link to this post

    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. Answer
    Cody
    Admin
    Cody avatar
    3360 posts

    Posted 11 Jun 2013 Link to this post

    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
  3. Connections Academy Developer
    Connections Academy Developer avatar
    63 posts
    Member since:
    May 2005

    Posted 13 Jun 2013 Link to this post

    Thank you. We'll follow the bug report.
Back to Top