2

I am trying to launch an external application for testing using UISpec4J.

Here are the questions and their answers I referred so far:

How to automate a swing java web start application which runs clicking a link into a web application, which is automated with Selenium WebDriver?

Getting all windows using UISpec4J

UISpec4J Capturing modal dialog, before the trigger finish

my.exe referred below is a Java application wrapped in exe using some tool. Internally it uses the jars and is Java GUI application.

This executable launches a splash screen first, then a dialog to choose where you want to connect to and after that main window is shown. Unless I can automate where I can connect to I won't get main window.

Based on these questions I have come up with following code fragments:

        this.setAdapter(new UISpecAdapter() {
        @Override
        public Window getMainWindow() {
            return WindowInterceptor.run(new Trigger() {
                @Override
                public void run() throws Exception {
                    // running jnlp by netx launcher 
                    Runtime.getRuntime().exec("C:\\my.exe"); 
                    Thread.sleep(10000);
                }
            });
        }
    });

In the approach above I simple get "No window was shown" error.

        this.setAdapter(new UISpecAdapter() {
        @Override
        public Window getMainWindow() {
            final Window[] result = new Window[1];
            WindowInterceptor
            .init(new Trigger() {
                @Override
                public void run() throws Exception {
                    Runtime.getRuntime().exec("C:\\my.exe"); 
                    //Thread.sleep(10000);
                }
              })
              //.processTransientWindow()
              .process(new WindowHandler() {
                    public Trigger process(Window window) throws Exception {
                    result[0] = window;
                    return Trigger.DO_NOTHING;
                    }
                })
            .run();
            return result[0];
        }
    });     

In the second approach above, I still get "No window shown" error AND control never reaches to overriden "process" method.

I referred to http://www.uispec4j.org/reports/apidocs/org/uispec4j/interception/WindowInterceptor.html and recommended approach is to use init to capture modal dialog is init\process sequence.

To capture non-modal it is recommended that we should use following:

   Window window = WindowInterceptor.run(panel.getButton("open").triggerClick());

But I have NO idea where and how I am supposed to call it..

From the first question I referred, mentioned above, we should be able to do that because the answer to it mentions launching jnlp application which is external application.

I tried with jre 6 update 0 and I can at least run test. In java update 37, from the third question I referred above, I get abstract method not implemented error.

What am I doing wrong? Any idea?

I am using latest UISpec4J package - version 2.4.

Thanks in advance, -Neel.

Community
  • 1
  • 1

1 Answers1

0

I'm very new to UISpec4J but I'm guessing it needs to run in the same JVM in order to intercept and interact with the GUI components. When you start the exe file with exec, it will create a new process and a new, separate JVM. That'll not work, if I understand UISpec4J correctly.

Regarding the non-modal example, the documentation says "You would retrieve the window from within the test...", so in a setup method or in a test should work.

levsa
  • 930
  • 9
  • 16
  • Thanks for comment. Had to raise another question for same app. Could you check whether you can help me there - http://stackoverflow.com/questions/28711933/launching-osgi-plugin-from-eclipse-plugin? –  Apr 22 '15 at 23:51
  • Sorry, I'm not familiar with osgi plugins. – levsa Apr 23 '15 at 13:52
  • i am not able to launch my jnlp file may be due to jre 1.7+ as my test project is using jre 1.6 and application under test uses 1.7+ I am getting following exception:Exception in thread "SPARCS N4" java.lang.UnsupportedClassVersionError: com/navis/framework/ulc/client/jnlp/CarinaJnlpLauncher : Unsupported major.minor version 51.0 – Sneh Tripathi Jun 12 '15 at 12:28