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
编辑检查点只是检查 WinEditor 的 Text 属性是否等于我们输入的内容:“A”、回车、换行、“B”。 (这正是编辑器包含的内容,您可以通过查看GetROProperty("Text")
来验证,它返回一个长度为4、ASCII 65、13、10、66的字符串,这正是我希望如此。)
如果我使用最后一个 Type 调用的活动屏幕创建检查点并使用其中包含的值,我会在对话框中获得“复杂值”编辑控件,用于编辑 Text 属性值。它支持只需按 Enter 键即可输入换行符。到目前为止,一切都很好。
如果我手动创建检查点并手动输入 Text 属性的预期值,我会在那里得到一个简单的编辑控件。我无法在那里输入带换行符的字符串。
问题是:如果我最初没有使用“复杂”值(例如没有换行符的字符串)创建检查点,如何使用复杂值编辑控件输入预期的字符串值?
如果我根本不能这样做,这将是一个设计故障 - 考虑一下:假设您使用活动屏幕创建它,然后将预期值编辑为一些微不足道的值。这导致从现在开始只能使用简单的编辑控件来编辑(微不足道的)预期值——而且我无法撤消我的更改并重新编辑预期值以包含换行符。
一种想法是创建一个正则表达式。上面示例的正则表达式为“A\cM\cJB”。然而,这不起作用。一个单独的问题(QTP:如何在多行编辑控件中匹配(或参数化)换行符?)询问原因,所以让我们在这里尝试避免这个问题中的正则表达式方面。 另外,我想知道如果不是作为正则表达式,如何将包含换行符的这些值参数化到数据表列中。我无法在数据表单元格中输入换行符。但是这个方面也在正则表达式问题中,所以我们在这里也避免这个方面。
Consider this script:
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
The edit checkpoint simply checks if the Text property of the WinEditor is equal to what we entered: "A", carriage return, line feed, "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.)
If I create the checkpoint by using the active screen of the last Type invocation and use the value contained therein, I get the "complex value" edit control in the dialog for editing the Text property value. It supports entering line breaks simply by pressing Enter. So far, so good.
If I create the checkpoint manually and enter the expected value for the Text property manually, I get a simple edit control there instead. I cannot enter a string with line breaks there.
The question is: How can I enter the expected string value using the complex value edit control if I did not initially create the checkpoint with a "complex" value, for example a string without line breaks?
If I cannot do that at all, this would be a design glitch -- consider this: Suppose you create it using the active screen, and then you edit the expected value to something trivial. That leads to the (trivial) expected value from now on being editable with the simple edit control only -- and I'd have no way to undo my change and re-edit the expected value to contain a line break.
One idea would be to create a regular expression. The regexp for above example would be "A\cM\cJB"
. This does not work, however. A separate question ( QTP: How do I match (or parametrize) line breaks in multiline edit controls?) asks why, so let's try to avoid this regexp aspect in this question here.
Also, I wonder how I would parametrize such values containing line breaks into a data table column if not as a regular expression. I cannot enter line breaks in a data table cell. But that aspect is also in the regexp question, so let's avoid that aspect here, too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
QTP 的制造商;) 承认这是“设计使然”:)
解决方法可能是使用更新模式来捕获包含 CR LF 序列的值。然后,可以返回到“复杂值”编辑对话框。
但 QTP GUI 显然没有提供摆脱编辑“死胡同”的方法。
The maker of QTP ;) acknowledged this is "by design" :)
A workaround might be to use update mode to catch the value including the value containing a CR LF sequence. Then, one can go back to the "complex value" edit dialog.
But the QTP GUI definetely provides no way to get out of the editing "dead end".