[英]How to identify java swing button in a GUI application and click on that button using another Java code in eclipse?
I'm trying to create a small application to do some automation. 我正在尝试创建一个小型应用程序以进行一些自动化。 I have a compiled and working GUI swing application that has a few buttons. 我有一个经过编译且可以使用的GUI Swing应用程序,该应用程序具有几个按钮。 I want to write another application in java using eclipse to do some automation on that GUI so my second application will click on the GUI buttons in specific order for example: 我想使用eclipse在Java中编写另一个应用程序以对该GUI进行一些自动化,因此我的第二个应用程序将按特定顺序单击GUI按钮,例如:
scenario 1: 方案1:
scenario 2: 方案2:
The button locations are dynamic so moving the mouse to exact coordinates will not work. 该按钮的位置是动态的,因此将鼠标移动到确切的坐标将不起作用。
I need to do something like UFT but very simple and using java in eclipse. 我需要做类似UFT的操作,但是非常简单,并且需要在eclipse中使用java。
Note: I don't want to use any already existing libraries or applications. 注意:我不想使用任何已经存在的库或应用程序。
You could use a Hashmap
. 您可以使用Hashmap
。 The key would be the text (or however you uniquely identify the button) of the button and the value would be the button. 键将是按钮的文本(或您唯一地标识按钮),而值将是按钮。
scenario 1: click on button 2 then button number 5 then button number 1 方案1:单击按钮2,然后单击数字5,然后单击数字1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.