简体   繁体   English

如何从Java代码访问小程序?

[英]How to access an applet from the java code?

We are developing an application which accesses an API exposed over some embedded system. 我们正在开发一种应用程序,该应用程序可以访问某些嵌入式系统上公开的API。 This API internally validates the user to provide the access to the embedded system. 该API在内部验证用户是否可以提供对嵌入式系统的访问。 To validate the call, it opens a dialog box and asks for username and password. 为了验证呼叫,它会打开一个对话框并询问用户名和密码。 This dialog box is essentially a Java applet opened in applet viewer. 此对话框实质上是在applet查看器中打开的Java applet。

We want to automate this whole process by building small exe or by doing the same in tomcat server. 我们希望通过构建小型exe或在tomcat服务器中执行相同的操作来自动化整个过程。 To do the same, we need get the object of the dialog box and fill the credentials. 为此,我们需要获取对话框的对象并填充凭据。 How can we achieve this. 我们如何实现这一目标。 There must be some way to automate the testing of applets which can be used to do the above task. 必须有某种方式可以自动完成小程序的测试,以完成上述任务。

Thanks for helping. 感谢您的帮助。 It will be great if someone can provide a code snippet or link for the same :) 如果有人可以提供相同的代码段或链接,那将是很好的:)

Reason why I want to have this kind of system: 我想拥有这种系统的原因:

We need to build an application which gets the memory status of PLC device. 我们需要构建一个获取PLC设备内存状态的应用程序。 This device is connected with heavy machines and has its own programming language via digital networks. 该设备与重型机器连接,并通过数字网络具有自己的编程语言。 To get the memory map, there are APIs exposed in java which communicates with assembly language. 为了获得内存映射,在Java中公开了与汇编语言进行通信的API。 We use these APIs to get the memory status of various memory variables from PLC device. 我们使用这些API从PLC设备获取各种内存变量的内存状态。 On the basis of the memory status we raise an alert by sending an email or SMS. 根据内存状态,我们通过发送电子邮件或SMS发出警报。 When we try to access the memory area of this device for the very first time, it pops up an authorization dialog box which asks for username and password of PLC device. 当我们第一次尝试访问该设备的存储区时,它会弹出一个授权对话框,要求您输入PLC设备的用户名和密码。

Hence, to automate the memory monitoring system which can send the alerts, we have to fill the authorization dialog box through java program or some of the other way. 因此,要使可以发送警报的内存监视系统自动化,我们必须通过Java程序或其他方式填充授权对话框。 When I access memory of PLC from java console program we need this authorization dialog to be filled by itself without any manual intervention. 当我从Java控制台程序访问PLC的内存时,我们需要自己填写此授权对话框,而无需任何手动干预。

So, How can we get an object of this dialog box? 那么,如何获得此对话框的对象?

I hope scenario is clear. 我希望情况清楚。 We don't need any framework to build which can automate the applet UI. 我们不需要构建任何可以使applet UI自动化的框架。 We just need for specific dialog box. 我们只需要特定的对话框。 Please help!! 请帮忙!!

You can do with with any number of Java GUI functional testing tools. 您可以使用任何数量的Java GUI功能测试工具进行处理。 Here's a good list, looks like FEST or Jemmy might be a good approach: 这是一个很好的列表,看起来像FEST或Jemmy可能是一个很好的方法:

Automated tests for Java Swing GUIs Java Swing GUI的自动化测试

It looks like they all build on top of java.awt.Robot so you can look at that if you want to roll your own. 看起来它们全部都建立在java.awt.Robot之上,因此如果您想自己滚动,可以查看一下。

If this does not work you may have to go to a native GUI testing framework. 如果这不起作用,则可能必须转到本机GUI测试框架。 Some good options are listed here for Windows: Windows列出了一些不错的选择:

https://stackoverflow.com/questions/120359/tools-for-automated-gui-testing-on-windows https://stackoverflow.com/questions/120359/tools-for-automated-gui-testing-on-windows

http://sikuli.org/ pretty good. http://sikuli.org/很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM