想要从 JAVA 编辑中删除文本并更新其中的新值

发布于 2024-09-15 14:56:05 字数 68 浏览 3 评论 0原文

我想删除 Java 编辑框中存在的文本,并想在该字段中添加新文本。

我如何在 QTP(脚本)中执行此任务?

I want to delete the text present in the Java Edit box and want to add a new Text into that feild.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧梦荧光笔 2024-09-22 14:56:05

@TestGeek

如果您想使用“ctl+A 并删除”序列,请使用 Edit 对象的 .Type() 方法。
如果您的对象不完全受 QTP 支持并且没有 .Type() 方法,您可以使用 WshShell.SendKeys() 作为解决方法(不要忘记首先将焦点放在对象上)。

在QTP中,常量以“mic”(Mercury Integer Constant)前缀定义。您可以在帮助中搜索完整列表。

对于您提到的那些,您需要以下内容:
micCtrlDwn
“A”
micCtrlUp
麦克风

@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

梦归所梦 2024-09-22 14:56:05

尝试使用对象本机函数 setText("")。这会将内容重置为空字符串。优点是只需 1 行即可完成工作。

.object 允许访问本机方法,并且仅当 UI 对象实际在屏幕上打开时,包含所有方法的工具提示才会出现在 qtp IDE 中。

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

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("")
玩世 2024-09-22 14:56:05

我对 Java 添加不是很熟悉,但据我所知,Set 方法替换了文本。如果您确实需要先清除它,可以设置为空字符串。

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

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" 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文