Forum Discussion

easy-soft's avatar
easy-soft
Occasional Contributor
4 years ago

Using Unicode with Recorder.AddSyntaxToScript

I have written my own record action (as script extension) to handle certain cases during test recording. The implementation of the record action uses `Recorder.AddSyntaxToScript` to add operations to the test being recorded. Unfortunately I noticed that this function is unable to handle Unicode correctly.

 

Example (very much simplified): 

 

function RecordExecute_CurrentControl_JS()
{
  var call;
  call = Syntax.CreateInvoke();
  call.ClassValue = 'BuiltIn';
  call.InvokeName = 'MessageDlg';
  call.IsProperty = false;
  call.AddParameter('‰Šš›‹žŽŸŒœ•€'); 

  Recorder.AddSyntaxToScript(call);      
}

 

This will end up in my keyword test as follows:

 

BuildIn    | MessageDlg    | "\\u2030Šš\\u203a\\u2039žŽŸŒœ\\u2022€" 

 

 

Is there any method I need to call on my string parameter to prepare it for `AddSyntaxToScript`?

 

P.S.: Recorder.AddTextToScript works just fine with any Unicode-String passed.

5 Replies

  • BenoitB's avatar
    BenoitB
    Community Hero
    so it works well because you get the good utf encoding. When you run it's not working ?
    • easy-soft's avatar
      easy-soft
      Occasional Contributor

      No, the given example does not work as expected. It displays a message box containing "\u2030Šš\u203a\u2039žŽŸŒœ\u2022€" and not my string passed from the JavaScript code. Thus the string is not interpreted correctly. Also the string ist not correctly displayed inside the keyword test editor.

       

      If I add operations using `AddTextToScript`, any unicode characters are displayed correctly inside the keyword test editor and also during execution of the test. 

      • BenoitB's avatar
        BenoitB
        Community Hero

        I dont know if in KWT you have to play with Project options Unit encoding ? (Tools / current project properties / General / Unit encoding). Perhaps try it ?