public void SetSession(string BoxName) { var application = SAPTestHelper.GetSAPGuiApp(); GuiConnection connection = null; GuiSession session = null; int index = application.Connections.Count - 1; if (index < 0) { throw new Exception("No SAP GUI Connections found"); } for (int i = 0; i < application.Children.Count; i++) { var con = application.Children.ElementAt(i) as GuiConnection; index = con.Sessions.Count - 1; if (index < 0) { throw new Exception("No SAP GUI Session Found"); } for (int j = 0; j < con.Sessions.Count; j++) { var ses = con.Children.ElementAt(j) as GuiSession; if (ses.Info.SystemName.ToLower() == BoxName.ToLower()) { session = ses; break; } } if (session != null) { connection = con; break; } } if (session != null) { SetSession(application, connection, session); } else { throw new Exception("No SAP GUI Session Found"); } }
public void SetSession() { var application = SAPTestHelper.GetSAPGuiApp(); int index = application.Connections.Count - 1; if (index < 0) { throw new Exception("No SAP GUI Connections found"); } var connection = application.Children.ElementAt(index) as GuiConnection; index = connection.Sessions.Count - 1; if (index < 0) { throw new Exception("No SAP GUI Session Found"); } var session = connection.Children.ElementAt(index) as GuiSession; SetSession(application, connection, session); }