Here is the code:
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);
ActiveBrowser.NavigateTo("http://www.telerik.com/products/free-testing-framework/overview.aspx");
var result = Actions.InvokeScript<Dictionary<string, string>>(JS);
}
[TestMethod]
public void testJavascriptReturnsDictionaryFirefox()
{
Manager.LaunchNewBrowser(BrowserType.FireFox);
ActiveBrowser.NavigateTo("http://www.telerik.com/products/free-testing-framework/overview.aspx");
var result = Actions.InvokeScript<Dictionary<string, string>>(JS);
}
[TestMethod]
public void testJavascriptReturnsDictionaryChrome()
{
Manager.LaunchNewBrowser(BrowserType.Chrome);
ActiveBrowser.NavigateTo("http://www.telerik.com/products/free-testing-framework/overview.aspx");
var result = Actions.InvokeScript<Dictionary<string, string>>(JS);
}
The functions for IE and Chrome work as expected. Firefox returns the error:
The Test method MySampleTests.TelerikVSUnitTest1.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