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.
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:
Place build files into any folder on your PC.
Add .jar files from this build to your testing project.
Open .jnlp file in text editor and search for main application class
application-desc main-class="[Main application class]"/>
Call it from you test to launch app
new ClassReference("[Main application class]").startApplication();
Now you can access elements of this Java app from test environment
You can use Jemmy with JUnit in NetBeans IDE.
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.
Another Approach:
You can also do it using jnlp. Already suggested #Sergey Grinev
A good example and running code is given in this link:
Snapshot:
Click the jnlp file link in webdriver, save jnlp file to disk;
Run the webstart app from jnlp;
Capture opened app and use it for test.
This process can be done by using following libraries:
netx - for running webstart application from jnlp.
uispec4j - for intercepting created webstart window and
manipulating window elements.
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
Jemmy Tutorial
Jemmy Samples
NetBeans Platform Test Infrastructure Tutorial
Related
What is the best way to create application that can be used both as GUI app and console tool?
Here is relative info: Can one executable be both a console and GUI application?
My question is more about Java, Maven, JavaFX - my app currently runs as JavaFX GUI application.
P.S. Any relative help, very appreciated. I am totally confused.
Probably do this:
Add an option like java -jar MyApp.jar -gui
Fall back to console if no GUI is available, e.g. Java runs in headless mode
Use the Console class for the console ui.
I'm writing Selenium tests using Java + Maven + Selenium WebDriver. Our customer wants these tests in such a way that they can run tests easily without much technical stuff needed.
I've all my tests under src\test\java folder. Is there any way where I can give jar file or so to the customer and they can run tests by simply clicking on it or by hitting some command on the command line.
Please point me to documentation or video using which I can achieve this.
I've been using Visual Studio to write my Selenium tests in C#. I am able to build my project to a console application in Visual Studio that contains the required files like the Chrome webdriver. It can be run from this single application file with one click. The console then prints out if the test is a success or if their are any exceptions. You should also be able to integrate a headless browser like selenium has on their site. This would allow the test to be run with one click and no browser will pop up while the tests are running.This is all the experience I have and it has worked well for me. Hope that this information can help a little.
The short version of this question is, how can I send a message (a file path, for example) from a Java application (NetBeans plugin, to be specific) to an already-running C# WinForms executable application?
Some details.
I currently have a Windows application that I built (it's like a parser/editor for script files to help automate the process of script building using simple GUI tools for our test team). In the application, you can load a file using the app's "Load" button, hotkey, drag/drop, etc. You can also open the application from the command line with one or more file paths as parameters, and the app will launch with the given files already loaded.
On request, I cobbled together a NetBeans plugin (Java) that grabs the file path of the file that is currently in focus in NetBeans, and then executes my application with the focused file's path as parameter. This allows me to launch my app directly from NetBeans and open the file being edited in NetBeans in my app.
So what my app can do:
Launch with file loaded from CLI parameter
Load file from internal load command on-the-fly
What it can't do (what I want to add):
Load file in running instance from external message parameter on-the-fly
Load file in running instance from CLI message parameter on-the-fly
MSMQ is a solution I can't use. Saw it suggested in a lot of other threads. Things to note are that the NetBeans plugin and my app will always be on the same system, but I can't get MSMQ on all target machines.
Two suggestions:
(1) If you can figure out a way to publish an event from a Java process into the windows event log, you can definitely set up your .net app to watch for specific event types
(2) If you can arrange for the .net app to watch for files being created in a particular directory using FileSystemWatcher (maybe in %TEMP%), you can have your Java process write a file that contains whatever info you wish to pass.
I have a Java application ready to be deployed. I tried using Java Web Start (JWS) to launch my application. My application was able to launch it loads the MainFrame but some of the functionality does not work. For example my search button (which creates a new thread to search information over the internet) is not working and several other buttons. My application works perfectly as intended when I run it using the typical java -jar or by double-clicking the JAR file. Do you have any ideas why did it happen? Or am I using a wrong technology for deployment? When I read about JWS the thing that I really like is the auto-updating of the application when new versions are released for the app. I really want this feature for future updates.
Solved:
I wasn't aware of the of Web Start Console. My problem is solved now as I was able to see the stack trace. It has something to do with permissions and my JAR file being unsigned.
I have one swing application that i want to run on browser.
What is the best way to achieve it ?
Is jnpl is one this solution ?
I tried jnpl but when i tries to run with -- http://localhost:8080/Test.jnlp -- One error window opens with error unable to launch application
If applet is the solution then , if possible please ,give me one sample applet application.
Thank you in advance
In fact, JNLP won't allow you to run your application a browser (as say the unofficial JNLP FAQ, JNLP!=Applet). It will instead allow you to easily distribute current (and nexts) version of your application to your clients, by simplifying the install process.
The simple way to do it is to transform your application into a real applet (complet with all its usage restrictions), then make this applet detachable, using new Java6 feature. I unfortunatly only found info on that very excellent feature in a blog post.