単一マシンで複数の UI セッションを持つアプリケーションや、単一マシンで複数のエージェントをテストするには、そのマシンで複数の Open Agent インスタンスに接続します。すべてのエージェントがそれ自身の UI セッションで実行します。UI セッションは、リモート デスクトップ プロトコル (RDP) や Citrix ベースの接続です。
// VB .NET code
Private agent As RemoteAgent = Agent.Connect("hostname:port")
// C# code
private RemoteAgent agent = Agent.Connect("hostname:port");
ここで、hostname はエージェントを実行しているマシンの名前で、port は指定した一意のポート番号で、HTTP ポートまたは HTTPS ポートのいずれかになります。
複数の UI セッションをホストしているサーバー マシンの名前を ui-srv とします。ポート番号 22903/48563、22904/48564、22905/48565 を使用して 3 つの UI セッションを作成します。
openAgent.exe -infoServicePort=22903 -infoServiceSecurePort=48563
他の 2 つのセッション対して、ポート番号 22904/48564 および 22905/48565 をそれぞれ使用して同じことを行います。
// VB .NET code
Private agent1 As RemoteAgent = Agent.Connect("ui-srv:22903") ' or 48563 for secure HTTPS communication
Private agent2 As RemoteAgent = Agent.Connect("ui-srv:22904") ' or 48564 for secure HTTPS communication
Private agent3 As RemoteAgent = Agent.Connect("ui-srv:22905") ' or 48565 for secure HTTPS communication
// C# code
private RemoteAgent agent1 = Agent.Connect("ui-srv:22903"); // or 48563 for secure HTTPS communication
private RemoteAgent agent2 = Agent.Connect("ui-srv:22904"); // or 48564 for secure HTTPS communication
private RemoteAgent agent3 = Agent.Connect("ui-srv:22905"); // or 48565 for secure HTTPS communication
// VB .NET code
<SilkTestClass()> Public Class TestMultiSession
Private agent1 As RemoteAgent = Agent.Connect("ui-srv:22903")
Private agent2 As RemoteAgent = Agent.Connect("ui-srv:22904")
Private agent3 As RemoteAgent = Agent.Connect("ui-srv:22905")
<TestMethod()> Public Sub Test()
Dim d1 As Desktop = agent1.Desktop
Dim d2 As Desktop = agent2.Desktop
Dim d3 As Desktop = agent3.Desktop
Dim baseState = New BaseState()
agent1.ExecuteBaseState(baseState)
agent2.ExecuteBaseState(baseState)
agent3.ExecuteBaseState(baseState)
d1.Window("@caption='My Application'").TypeKeys("Hello to session 1!")
d2.Window("@caption='My Application'").TypeKeys("Hello to session 2!")
d3.Window("@caption='My Application'").TypeKeys("Hello to session 3!")
End Sub
End Class
// C# code
[SilkTestClass]
public class TestMultiSession {
private RemoteAgent agent1 = Agent.Connect("ui-srv:22903");
private RemoteAgent agent2 = Agent.Connect("ui-srv:22904");
private RemoteAgent agent3 = Agent.Connect("ui-srv:22905");
[TestMethod]
public void Test() {
Desktop d1 = agent1.Desktop;
Desktop d2 = agent2.Desktop;
Desktop d3 = agent3.Desktop;
BaseState basestate = new BaseState();
agent1.ExecuteBaseState(basestate);
agent2.ExecuteBaseState(basestate);
agent3.ExecuteBaseState(basestate);
d1.Window("@caption='My Application'").TypeKeys("Hello to session 1!");
d2.Window("@caption='My Application'").TypeKeys("Hello to session 2!");
d3.Window("@caption='My Application'").TypeKeys("Hello to session 3!");
}
}