assertj / assertj-swing

Fluent assertions for Swing apps
Other
107 stars 52 forks source link

Launching an application (Jprofiler specifically) by its executable #200

Closed sriramnagaraj closed 7 years ago

sriramnagaraj commented 7 years ago

I need to automate JProfiler GUI (switching between various tabs, extracting textual data and verifying them). I have been trying to use assertj-swing library. However, JProfiler is launched by an executable and not by class file. Is there a method in assertj swing to launch a app by its executable. ?

croesch commented 7 years ago

Hi,

unfortunately there is no way to start an application via executable with plain AssertJ-Swing.

However I think you don't need this. There are two approaches that I would suggest:

  1. Find the main class. I don't know on which platform you're working.. But have a look at the tar.gz package of JProfiler for Linux. You might be able to find the main class:
521 $INSTALL4J_JAVA_PREFIX exec "$app_java_home/bin/java" [..] com.install4j.runtime.launcher.UnixLauncher launch 388cfb98 "" "" com.jprofiler.frontend.FrontendA    pplication  "$@"

So I would suggest playing around with these two classes and hopefully you're able to run JProfiler from its main class. Even if it has an executable (under Linux this is just a script) it needs a Main class. And if you find it you can use it to run the application - JProfiler in your case - with AssertJ-Swing.

  1. Launch the two programs in the same JVM. I never tried this, but there are several ways to call executables out of Java.. also there might be a solution to run two Java applications in the same JVM. From what I know, this is all you need.

So if you manage to run two executables in the same JVM - AssertJ-Swing should find your UI..

Let me know if and what works for you.

Cheers Christian

sriramnagaraj commented 7 years ago

Hey croesch,

Thanks for the information. Yes, as u suggested, there was the class file "com.jprofiler.frontend.FrontendApplication" and Jprofiler GUI was invoked by assert-jswing

public static String JC_LAUNCH_CLASS = "com.jprofiler.frontend.FrontendApplication"; APPLICATION = ApplicationLauncher.application(JC_LAUNCH_CLASS);

AtulK85 commented 6 years ago

Just wanted to check, if with any recent updates is it possible to launch and Java Swing based desktop application to do UI test via assertJ Swing.

Alternatively, can I launch it manually and by any command make assertJ Swing recognize the Frame and continue UI test on it?

Any help / guidance will be highly appreciated.

Thanks in advance.