dzharii / swd-recorder

Selenium WebDriver Page Recorder (Page Objects)
MIT License
189 stars 71 forks source link

JSON Error (Error converting value) on JSF pages #12

Closed dzharii closed 10 years ago

dzharii commented 10 years ago

This issue was reported by Vlad via Email.
On web applications built with JSF framework standard JavaScript side JSON object is changed when serializing arrays.

As results, the following error occurs in SWD Page Recorder:
2013-09-02 13:22:05.0123 ERROR Error converting value "[{"Key": "type", "Value": "text"}, {"Key": "class", "Value": "long-input  "}, {"Key": "maxlength", "Value": "64"}, {"Key": "value", "Value": ""}, {"Key": "name", "Value": "name"}, {"Key": "id", "Value": "name"}]" to type 'System.Collections.Generic.List`1[System.Collections.Generic.KeyValuePair`2[System.String,System.String]]'. Path '', line 1, position 261.
2013-09-02 13:22:05.7904 INFO VisualSearch_UpdateSearchResult: Finished

Looks like standard JSON object behavior was changed by JSF. The following experiment shows different behavior for same calls in same browser for default and JSF pages:

http://www.toysrus.co.uk/index.jsf

JSON.stringify([{Key : "1", Value : "s}dsd" + '"' + "z"}], null);
""[{\"Key\": \"1\", \"Value\": \"s}dsd\\\"z\"}]""

about:blank

JSON.stringify([{Key : "1", Value : "s}dsd" + '"' + "z"}], null);
"[{"Key":"1","Value":"s}dsd\"z"}]"

The problem was fixed by generating json string without using JSON object.

vbachurin commented 10 years ago

Works fine now. Thank you Dmitry!