问题
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.
回答1:
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".
来源:https://stackoverflow.com/questions/5554229/qtp-how-do-i-get-the-complex-value-edit-control-in-the-checkpoint-property-ed