捕获 Java 生成的 JFrame 弹出窗口
我将使其简短而具体。我正在黑盒测试 Java 中的命令行实用程序(IDE:Eclipse),在某些时候它会生成一个 JFrame 弹出窗口,要求输入密码。由于我正在进行一系列自动化测试,因此必须自动输入密码。弹出窗口上没有按钮,因此密码+回车键就足够了。
我应该制作某种等待弹出窗口的侦听器或事件处理程序,捕获它并输入密码吗?也许某种进程监听器?
任何帮助将不胜感激!
I'll make it short and specific. I am blackbox testing a commandline utility in Java (IDE: Eclipse) and at some point it generates a JFrame pop-up, which asks for password. Since I'm making series of automated tests, the password has to be entered automatically. There is no button on the popup so password + enter key is enough.
Should I make somekind of listener or eventhandler, which is waiting for the pop-up, catch it and enter the password? Maybe somekind of process listener?
Any help will be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为您的输入字段和按钮命名 (Component.setName()) 并使用 FEST 框架来机器人控制您的 UI:http ://fest.easytesting.org/
但是:对于像这样的情况,能够通过命令行(绕过 gui)给出密码和用户名或从配置文件中读取它可能更有趣。 (无论如何,两者稍后都可能会添加到实用程序中)
Give your input field and your button a name (Component.setName()) and use the FEST framework to robot control your UI: http://fest.easytesting.org/
But: for cases like this it might be more interesting to be able to give the passwd and username either via the commandline (bypassing the gui) or read it from a config file. (Both will later likely be added to the utillity anyway)