froglogic / All / Extending the script bindings for Java

Extending the script bindings for Java

Testing with the Squish Qt edition, one can add (from the Squish documentation)
var num = QInputDialog.getInteger( "Require User Input", "How many pages have been printed?" );
in the scripts. So testers can fill-in data that the program can’t see.
Unfortunately testing with the Java edition and using the SWT toolkit, there is no such a ready-to-use dialog for this.

However, the Java edition of Squish is easily extended because classes are dynamically wrapped at application startup. We must therefor write an input dialog ourselves, tell Squish about it and call it from our test scripts.

So first write a simple input dialog

package com.froglogic;
import org.eclipse.swt.widgets.*;

public class Input
public static String getMessage( Shell parent, String question ) {

The implementation is in the file, together with a jar file containing the compiled classes of the sources.

Now we must add the .jar to our classpath. (Btw. Squish 3.2.1 will now finally have an editbox for setting the classpath and main class in the testsuite settings dialog.)

Next we must tell Squish that we want to wrap the new classes. So we must carry out the task “Wrapping custom Java™ classes” from the Squish User Guide.
Basically write a .ini file, like:


and register this by squishserver:

squishserver --config setConfig MyAUT /path/extras.ini

Finally use the code in our scripts. I’ve put it here just after the script is waiting for a CCombo widget:

var shell = findObject(":Buttons_org.eclipse.swt.custom.CCombo").shell;
test.log(com_froglogic_Input.getMessage(shell, "What's your name?"));

In the code above the return value is directly printed in the test results.
Note that the property is a synthetic property, I’ve could have used CCombo.getShell() as well.

Summarizing, it requires some work but it is not very hard and without modifying any code of the application we’re testing.




My Environment:
– WinXP SP3
– Squish for QT Version: 3.4.3

i could’t call a java Method from *.jar (archive) file (I use JS as Test Suite language).

Used Files:

Server.ini file:

register this by squishserver
>>squishserver –config setConfig MyClassName ./server.ini

squishserver –config setJavaVM “C:Program FilesJavajre6clientjvm.dll”
squishserver –config setConfig MyClassName ..myappsxyzjava_archive.jar

In my Test Suite:
If i declare a new object in JavaScript with:
function main(){
var MyNewObject = new MyClassName();

i become exception “Can’t find variable” MyClassName.

Please help me.

> AutClasses=�java_archive/MyClassName�

This doesn’t look correct. You should only list class names. In the sever log you should see that an extra class gets registered and if you don’t see an exception, then Squish knows about this class

Leave a Reply

Your email address will not be published. Required fields are marked *

Copy link
Powered by Social Snap