I need to create some gui tests using Jemmy but I have no idea how to launch it with javaws application. In tutorials/examples/etc is something like that:
new ClassReference("org.netbeans.jemmy.explorer.GUIBrowser")
.startApplication();
This code opens an example window, but how can I, using ClassReference object open *.jnlp
file? Or is it another way to "connect" jemmy with java web start application?
Thanks for advance.
Highlight the JNLP file by tapping or clicking . JNLP under the Extensions column, then tap or click on Change Program. Tap or Click Java™ Web Start Launcher from the list of programs. If you do not see Java Web Start Launcher listed, tap or click More options then Look for another app on this PC.
In order to automate Java applications, particular settings must be in place. To install the Java configuration manually, after Power Automate for desktop has been installed, navigate to the installation folder (C:\Program Files (x86)\Power Automate Desktop) and run the PAD. Java. Installer.exe as an administrator.
Oracle has announced that Java Applet and WebStart functionality, including the Applet API, The Java plug-in, the Java Applet Viewer, JNLP and Java Web Start (containing the javaws tool) are all deprecated in JDK 9 and will be removed in a future release.
You can achieve this by preparing special build with Jemmy included and call Jemmy from the app run in jnlp mode itself.
The solution is:
.jar
files from this build to your testing project..jnlp
file in text editor and search for main application class
application-desc main-class="[Main application class]"/>
new ClassReference("[Main application class]").startApplication();
Now you can access elements of this Java app from test environment
For the GUI testing we are using Jemmy, a library that comes with the NetBeans IDE and is very useful for testing Swing applications.
JUnit tests that utilize Jemmy so for example:
@Test
public void JunitTest() {
JFrameOperator mainFrame = new JFrameOperator();
JTextFieldOperator textField = new JTextFieldOperator(mainFrame, "textIn");
int x = 10;
assertEquals(x, textField.getLocationOnScreen().x);
}
Adding the @Test
annotation and making use of JUnit's assertEquals()
and fail()
if needed.
You can also do it using jnlp. Already suggested @Sergey Grinev
Snapshot:
You can probably do the same trick with other AWT/Swing testing tool, but uispec4j allows to intercept webstart app executed from jnlp, you don't need to run the app by calling main() and you don't need to have your webstart app source code in your testing code repo.
Credit goes to tporeba
For learning more about Jemmy, you can go through this link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With