private static void InitializeOrphanedSession() { // Create new calculator session and close the window to get an orphaned element CleanupOrphanedSession(); orphanedSession = CreateNewSession(CommonTestSettings.CalculatorAppId); orphanedElement = orphanedSession.FindCalculatorTitleByAccessibilityId(); orphanedWindowHandle = orphanedSession.CurrentWindowHandle; orphanedSession.Close(); }
public void CreateSessionFromExistingWindowHandle_ModernApp() { // Get the top level window handle of a running application secondarySession = Utility.CreateNewSession(CommonTestSettings.CalculatorAppId); var existingApplicationTopLevelWindow = secondarySession.CurrentWindowHandle; // Create a new session by attaching to an existing application top level window DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("appTopLevelWindow", existingApplicationTopLevelWindow); session = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); // Verify that newly created session is indeed attached to the correct application top level window Assert.AreEqual(secondarySession.CurrentWindowHandle, session.CurrentWindowHandle); Assert.AreEqual(secondarySession.FindCalculatorTitleByAccessibilityId(), session.FindCalculatorTitleByAccessibilityId()); }