开发者

Want to delete the text from the JAVA Edit and update a new value in that

I want to delete the text present in the Java Edit box and want 开发者_Go百科to add a new Text into that feild.

How can i perform this task in QTP (Scripting)?


@TestGeek

If you want to use "ctl+A and delete" sequence, use .Type() method of Edit object.
If your object is not fully supported by QTP and does not have .Type() method, you can use WshShell.SendKeys() as a workaround (don't forget to set focus on the object first).

In QTP, constants are defined with "mic" (Mercury Integer Constant) prefix. You can search for the full list in help.

For those, that you mentioned, you need the following:
micCtrlDwn
"A"
micCtrlUp
micDel


Try using the objects native function setText(""). This resets the contents to an empty string. The advantage is that is does the job in 1 line.

The .object allows access to the native methods, and a tooltip with all methods will appear in the qtp IDE only if the UI object is actually open on the screen.

JavaWindow("win").JavaInternalFrame("frame").JavaEdit("edit").Object.setText("")


I'm not very familiar with the Java add in but AFAIK the Set method replaces the text. If you really need to clear it first you can set to the empty string.

 JavaWindow("win").JavaEdit("box").Set "" ''# Clear old text (optional)
 JavaWindow("win").JavaEdit("box").Set "new value" 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜