Forum Discussion
- TanyaYatskovskaSmartBear Alumni (Retired)
Hi Prakash,
It would be great if you posted the full problematic line here.
BTW, what TestComplete version are you using (Help | About...)?
- ThunduBeediOccasional ContributorTestComplete version is 8.20
Dim string = "line1[Enter]line2"
Set TestObject = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1).Window("Edit", "", 1)
TestObject.Keys(string)
This will type line1, Enter key and line2.
But, if instead of [Enter] if we use the actual character for Enter key which is \r\n or \n or \r, TestObject.Keys will type Enter key twice. - TanyaYatskovskaSmartBear Alumni (Retired)
Hi Thundu,
Thanks for the example. Actually, this behavior is specific to the Keys method. It recognizes \r as Enter and \n as Ctrl+Enter. That's why when you type \r\n two enters will be typed. I recommend that you use the SetText method instead of Keys.
@Prakash, if you were talking about \r\n, the SetText method will help you as well.
- prakash_vasudevContributorTanya,
SetText method documentation says "The SetText action sets the contents of an edit control, that is, replaces the previous contents with the specified text."
In case if we already have a text in the edit control it will completly replaced by the new text and we may be loosing the earlier text. This might not be of help to us. We are using keys method so that we can enter text on the control without loosing earlier. - TanyaYatskovskaSmartBear Alumni (Retired)
Hi Prakash,
This can be resolved in the following way:
Dim string
string = obj.wText
obj.SetText(string&"new text")
The SetText method is more powerful. It allows you to type some symbols indicated as hot keys in the Keys method (for example, [, !, etc.) in text controls.
Related Content
- 3 years ago
- 4 years ago
- 4 years ago
Recent Discussions
- 6 days ago
- 6 days ago
- 9 days ago