QTP:如何匹配(或参数化)多行编辑控件中的换行符? [英] QTP: How do I match (or parametrize) line breaks in multiline edit controls?

查看:73
本文介绍了QTP:如何匹配(或参数化)多行编辑控件中的换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑这个脚本:

SystemUtil.Run "notepad.exe"
With Window("Notepad")
    .WinEditor("Edit").Type "A"
    .WinEditor("Edit").Type  micReturn
    .WinEditor("Edit").Type "B"
  .WinEditor("Edit").Check CheckPoint("Edit")
End With

编辑"检查点只是检查编辑"WinEdit 是否包含A"、CR、LF、B".(这正是编辑器包含的内容,您可以通过查看GetROProperty ("Text") 进行验证,它返回长度为 4 的字符串,ASCII 为 65、13、10、66,这正是我期望.)在录制脚本并通过活动屏幕 click-o-magic 插入检查点后,我可以轻松创建这样的检查点.

The "Edit" checkpoint simply checks if the "Edit" WinEdit contains "A", CR, LF, "B". (This is exactly what the editor contains, you can verify by looking at GetROProperty ("Text"), it returns a string of length 4 with ASCII 65, 13, 10, 66, which is exactly what I'd expect.) I can easily create such a checkpoint after recording the script and inserting the checkpoint via active screen click-o-magic.

但现在假设我想参数化预期的字符串.由于我无法在数据表单元格中输入换行符,我会将预期的字符串转换为正则表达式,例如 "A\cM\cJB" 上面的例子.无论我是否将该正则表达式放入数据表中,它都不匹配.为什么?

But now suppose I want to parametrize the expected string. Since I cannot enter line breaks in a data table cell, I would convert the expected string to a regular expression, for example "A\cM\cJB" for above example. No matter if I put that regex into a data table or not, it does not match. Why?

或者有没有其他方法可以对包含换行符的预期字符串进行参数化?

Or is there any other way to parametrize an expected string containing a line break?

另见问题QTP:我如何获得复数值"?检查点属性编辑对话框中的编辑控件?.

推荐答案

事实:

  1. 中的换行符检查点的期望值不是支持.虽然这似乎显而易见,实际上所有正则表达式标记对于换行符,包括 \cM\cJ,未按预期方式处理.
  2. 值是否为在数据表中(作为数据表检查点的参数)或插入检查点直接.
  3. 支持人员说这是因为用于在 QTP 中实现数据表编辑器的第三方 Formula1 组件不能使用换行符.
  4. (3) 不可能是真的,因为那样 (2) 就不会是真的.
  5. 支持建议在数据表中放入一个公式来提供所需的字符串,例如 '="A"+Chr(13)+Chr(10)+Chr("B")'.

  1. Newline characters in the checkpoint's expected value are not supported. While this seems obvious, in fact all regex tokens for newline, including \cM and \cJ, are not handled in the expected way.
  2. It does not matter if the value is in the datatable (being a datatable parameter for the checkpoint) or inserted into the checkpoint directly.
  3. Support says this is because the third-party Formula1 component used to implement the data table editor in QTP cannot use newline characters.
  4. (3) cannot be true because then (2) would not be true.
  5. Support suggests to put a formula into the data table which delivers the wanted string, for example '="A"+Chr(13)+Chr(10)+Chr("B")'.

我觉得这很令人愉快.

所以,我再一次回答了我自己的问题,但不是为了赢得尊重点(我会赢得点数吗?),而是与大家分享解决方案"或解决方法.

So once again, i answered my own question, but not to earn the respect points (will I earn any?), but to share the "solution", or workaround, with everybody.

使用的 QTP 版本是 10.00.

The QTP version used was 10.00.

这篇关于QTP:如何匹配(或参数化)多行编辑控件中的换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆