Testing Applications in Multiple UI Sessions on a Single Machine

To test applications in multiple UI sessions on a single machine or to test multiple agents on a single machine, connect to multiple Open Agent instances on the machine. Every agent runs in its own UI-session. A UI session can be a Remote Desktop Protocol (RDP) connection or a Citrix-based connection.

  1. Create the UI sessions.
  2. Open a command line window.
  3. Navigate to the folder /ng/agent in the Silk Test installation directory. For example, the default folder path might look like the following: C:\Program Files (x86)\Silk\SilkTest\ng\agent.
  4. In each UI session, execute the following command: openAgent.exe -infoServicePort=<port>.
    Note: Use a unique port number, because this port will be used in your Silk4J script to identify the Open Agent and the UI session in which the agent is running.
  5. Change your Silk4J scripts to connect to the Open Agent instances. To connect to an Open Agent instance, add the following line to the script:
    Desktop desktopSession = new Desktop("hostname:port");
    Where hostname is the name of the machine on which the agent is running, and port is the unique port that you have specified.
The resulting objects are independent of each other and can be used either in one thread or in multiple threads.
Note: If you want to launch an application in multiple UI sessions, you have to execute the base state for each UI session.
Note: To use TrueLog when testing applications in multiple UI sessions on a remote machine, you need to manually copy any generated TrueLog files from the remote machine to your local machine.


Assume that the server machine that is hosting the UI sessions is named ui-srv. You can create three UI sessions by using the ports 22903, 22904, and 22905.

In the first session, open the command line window, navigate to the agent directory, and type the following:
openAgent.exe -infoServicePort=22903

Do the same for the other two sessions with the respective ports 22904 and 22905.

To connect to the Open Agent instances, add the following code to your script:
Desktop desktopSession1 = new Desktop("ui-srv:22903");
Desktop desktopSession2 = new Desktop("ui-srv:22904");
Desktop desktopSession3 = new Desktop("ui-srv:22905");
The following sample script prints a simple text to each of the three UI sessions:
public class TestMultiSession {
  Desktop d1 = new Desktop("ui-srv:22903");
  Desktop d2 = new Desktop("ui-srv:22904");
  Desktop d3 = new Desktop("ui-srv:22905");
  public void test() {
    BaseState basestate = new BaseState();
    d1.<Window>find("//Window").typeKeys("Hello to session 1!");
    d2.<Window>find("//Window").typeKeys("Hello to session 2!");
    d3.<Window>find("//Window").typeKeys("Hello to session 3!");