If you are using Silk4J to replay a test against a java application that has a login dialog which then opens the main window, sometimes Silk4J cannot properly recognise the application on playback. In this instance you may get an error message similar to the following:

com.borland.silktest.jtf.common.UnsupportedMethodException: The method Control::SetActive is not supported. at com.borland.silktest.jtf.Agent.invoke(Agent.java:443)

In this instance you will need to tell Silk4J not to run the basestate and create your own code that invokes the application.  Open a new project in Silk4J and then create a new class.  You will need to create code something like the following example to invoke your application.  In this code sample Silk4J is running a .bat file to invoke one of the SilkTest sample applications.

package test2;

import java.io.IOException;

import com.borland.silktest.jtf.Desktop;
import org.junit.Before;
import com.borland.silktest.jtf.BaseState;
import org.junit.Test;
import com.borland.silktest.jtf.Window;
import com.borland.silktest.jtf.Menu;
import com.borland.silktest.jtf.common.types.Point;
import com.borland.silktest.jtf.common.types.ModifierKey;
import com.borland.silktest.jtf.MenuItem;
import com.borland.silktest.jtf.PushToolItem;
import com.borland.silktest.jtf.PushButton;


public class test2
{


 private Desktop desktop = new Desktop();

 //@Before
 //public void baseState() {
  //BaseState baseState = new BaseState("silk4j.settings");
  //baseState.execute(desktop);
 //}


 @Test
 public void test(2)
 {
  Runtime rt = Runtime.getRuntime();
  try {
   Process proc = rt.exec("cmd /c start C:\\SWT_32_Launcher.bat");
   // add further code here to deal with login window and set the main window active
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }


}

Notice how I have commented out the code to run the basestate?  The basestate code simply invokes the application and waits for the main window to open.  You can also invoke the application by running the application's executable, in the below snippet I am opening Notepad and setting the window active:

package test2;


import java.io.IOException;

import com.borland.silktest.jtf.Desktop;
import org.junit.Before;
import com.borland.silktest.jtf.BaseState;
import org.junit.Test;
import com.borland.silktest.jtf.Window;
import com.borland.silktest.jtf.Menu;
import com.borland.silktest.jtf.common.types.Point;
import com.borland.silktest.jtf.common.types.ModifierKey;
import com.borland.silktest.jtf.MenuItem;
import com.borland.silktest.jtf.PushToolItem;
import com.borland.silktest.jtf.PushButton;


public class test2
{


 private Desktop desktop = new Desktop();

 //@Before
 //public void baseState() {
  //BaseState baseState = new BaseState("silk4j.settings");
  //baseState.execute(desktop);
 //}


 @Test
 public void test2()
 {
  Runtime rt = Runtime.getRuntime();
  try {
   Process proc = rt.exec("Notepad.exe");
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  desktop.find("/Window[@caption='Untitled - Notepad']").setActive();
 }


}

Again I have commented out the code to run the basestate and instead using rt.exec(“Notepad.exe”) to invoke Notepad.  You can then use the locators as normal to run commands such as the window.SetActive() command.

Incident #2534982