如何在 TestComplete 工具中取消特殊字符的按键模拟?
谁能告诉我如何取消 TestComplete 中特殊字符的模拟?
我正在尝试向 runas
窗口发送密码,如下所示:
hCmd.Keys(a_Password + "[Enter]")
其中 hCmd
是 runas
命令窗口的句柄。
但是,如果密码值包含任何特殊字符,例如 !
或 ^
,TestComplete 会模拟 Shift 或 Ctrl 等键。
有没有办法通过 TestComplete 取消此类操作对于键中的指定部分(例如密码前后的 HTML 标记),以便所有字符都将按这些标记之间的位置键入?
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 window.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要通过将这些特殊字符加倍来转义它们:
!
→!!
~
→~~
^
→^^
[
→[[
这个其实在文档。
如果您要从外部源检索
a_Password
值,则只需在将其传递给Keys
方法之前执行字符串替换即可。例如:字符串替换是我所知道的唯一解决方案,并且是一个非常简单的解决方案。另请注意,仅当您使用
Keys
“键入”文本时才需要这样做。当您使用wText
或类似属性以编程方式设置文本时,无需转义这些特殊字符或以其他方式预处理文本。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 theKeys
method. For example: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 usingwText
or similar properties, there's no need to escape those special characters or otherwise preprocess the text.