开发者

How to nullify keys simulation for special characters in TestComplete tool?

Can anyone tell me how to nullify the simulation for special characters in TestComplete?

I am trying to send a password to the runas window like:

hCmd.Keys(a_Password + "[Enter]")

where hCmd is the handle for the runas command windo开发者_如何转开发w.

But if the password value contains any special characters like ! or ^, TestComplete is simulating the keys to Shift or Ctrl etc..

Is there a way to nullify such operation by TestComplete for a specified part in the keys like a HTML tag before and after the password so that all characters will be typed as it is between these tags?


You need to escape these special characters by doubling them:

!!!

~~~

^^^

[[[

This is actually mentioned in the key code table in the documentation.


If you are retrieving the a_Password value from an external source, then simply do a string replace before passing it to the Keys method. For example:

a_Password = a_Password.replace("!", "!!").replace("~", "~~").replace("^", "^^").replace("[", "[[");
// or
a_Password = a_Password.replace(/[!~^[]/g, "$&$&");


Just curious to know if there any solution provided by Testcomplete for such scenarios?

String replace is only solution I'm aware of, and is a pretty simple one. Note also that this is only needed when you "type" text using Keys. When you set the text programmatically using wText or similar properties, there's no need to escape those special characters or otherwise preprocess the text.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜