Your tests can understand JSON (JavaScript Object Notation) and can handle strongly typed objects returned from JavaScript. This might be a bit advanced for regular testers implementing test automation. However, if you are building mini-frameworks on top of Telerik Testing Framework, it is a great tool to help you get rid of having to parse complex strings returned by the InvokeScript function.

This is a basic example of how to use JSON:

[TestMethod]
public void KeyValuePairs()
{
Manager.LaunchNewBrowser();
// We are using a dummy call here. The call can be to any JS method on your page
JsonObject o = ActiveBrowser.Actions.InvokeScript<JsonObject>(
"({key1:'value1', key2:'value2'})");
Assert.AreEqual<string>("value1", o["root"]["key1"]);
Assert.AreEqual<string>("value2", o["root"]["key2"]);
}

<TestMethod()> _
Public Sub KeyValuePairs()
Manager.LaunchNewBrowser()
' We are using a dummy call here. The call can be to any JS method on your page
Dim o As JsonObject = ActiveBrowser.Actions.InvokeScript(Of JsonObject)("({key1:'value1', key2:'value2'})")
Assert.AreEqual(Of String)("value1", o("root")("key1"))
Assert.AreEqual(Of String)("value2", o("root")("key2"))
End Sub

Getting Started

Community

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.