When you return an array from JavaScript, .NET bindings return ReadOnlyCollection<object> , not List<object> . The reason for this is because you cannot expect the contents of the returned collection to change and update it in JavaScript on the page. The following is an example taken from a WebDriver project, native .NET integration tests .
List<object> expectedResult = new List<object>(); expectedResult.Add("zero"); expectedResult.Add("one"); expectedResult.Add("two"); object result = ExecuteScript("return ['zero', 'one', 'two'];"); Assert.IsTrue(result is ReadOnlyCollection<object>, "result was: " + result + " (" + result.GetType().Name + ")"); ReadOnlyCollection<object> list = (ReadOnlyCollection<object>)result; Assert.IsTrue(CompareLists(expectedResult.AsReadOnly(), list));
source share