예제 #1
0
        public void ErrorCloseWindowAlreadyClosedApplication()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.AlarmClockAppId);
            IOSDriver <IOSElement> singleWindowSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(singleWindowSession);
            Assert.IsNotNull(singleWindowSession.SessionId);

            // Close the application window without deleting the session
            singleWindowSession.Close();
            Assert.IsNotNull(singleWindowSession);
            Assert.IsNotNull(singleWindowSession.SessionId);

            // Attempt to close the previously closed application window
            try
            {
                singleWindowSession.Close();
                Assert.Fail("Exception should have been thrown");
            }
            catch (System.InvalidOperationException e)
            {
                Assert.AreEqual("Currently selected window has been closed", e.Message);
            }

            singleWindowSession.Quit();
        }
예제 #2
0
        public void ErrorTouchClosedWindow(string touchType)
        {
            JObject enterRequestObject = new JObject();

            enterRequestObject["element"] = session.FindElementByAccessibilityId("m_newTabPageGoButton").GetAttribute("elementId");
            session.Close();
            HttpWebResponse response = SendTouchPost(touchType, enterRequestObject);

            Assert.Fail("Exception should have been thrown because there is no such window");
        }
예제 #3
0
        public void GetWindowHandlesClassicApp()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.NotepadAppId);
            IOSDriver <IOSElement> multiWindowsSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(multiWindowsSession);
            Assert.IsNotNull(multiWindowsSession.SessionId);

            var windowHandlesBefore = multiWindowsSession.WindowHandles;

            Assert.IsNotNull(windowHandlesBefore);
            Assert.IsTrue(windowHandlesBefore.Count > 0);

            multiWindowsSession.FindElementByName("File").Click();
            multiWindowsSession.FindElementByName("Save As...").Click();

            System.Threading.Thread.Sleep(1000); // Sleep for 1 second
            var windowHandlesAfter = multiWindowsSession.WindowHandles;

            Assert.IsNotNull(windowHandlesAfter);
            Assert.AreEqual(windowHandlesBefore.Count + 1, windowHandlesAfter.Count);

            foreach (var windowHandle in windowHandlesAfter)
            {
                multiWindowsSession.SwitchTo().Window(windowHandle);
                multiWindowsSession.Close();
            }

            multiWindowsSession.Quit();
        }
예제 #4
0
        public void SwitchWindows()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId);

            IOSDriver <IOSElement> multiWindowsSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(multiWindowsSession);
            Assert.IsNotNull(multiWindowsSession.SessionId);

            multiWindowsSession.FindElementByAccessibilityId("m_actionsMenuButton").Click();
            multiWindowsSession.FindElementByAccessibilityId("m_newWindow").Click();

            System.Threading.Thread.Sleep(1000); // Sleep for 1 second
            var windowHandlesAfter = multiWindowsSession.WindowHandles;

            Assert.IsNotNull(windowHandlesAfter);

            foreach (var windowHandle in windowHandlesAfter)
            {
                multiWindowsSession.SwitchTo().Window(windowHandle);
                Assert.AreEqual(multiWindowsSession.CurrentWindowHandle, windowHandle);
                multiWindowsSession.Close();
            }

            multiWindowsSession.Quit();
        }
예제 #5
0
        public void ErrorGetClosedSessionElementScreenshot()
        {
            // Launch calculator for this specific test case
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.CalculatorAppId);
            IOSDriver <IOSElement> calculatorSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(calculatorSession);
            Assert.IsNotNull(calculatorSession.SessionId);

            try
            {
                calculatorSession.Close();
                IOSElement element = calculatorSession.FindElementByAccessibilityId("AppNameTitle");
                element.GetScreenshot();
                Assert.Fail("Exception should have been thrown because there is no such window");
            }
            catch (System.InvalidOperationException exception)
            {
                Assert.AreEqual("Currently selected window has been closed", exception.Message);
            }

            calculatorSession.Quit();
            calculatorSession = null;
        }
예제 #6
0
        public void GetWindowHandlesModernApp()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId);
            IOSDriver <IOSElement> multiWindowsSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(multiWindowsSession);
            Assert.IsNotNull(multiWindowsSession.SessionId);

            var windowHandlesBefore = multiWindowsSession.WindowHandles;

            Assert.IsNotNull(windowHandlesBefore);
            Assert.IsTrue(windowHandlesBefore.Count > 0);

            // Preserve previously opened Edge window(s) and only manipulate newly opened windows
            List <String> previouslyOpenedEdgeWindows = new List <String>(windowHandlesBefore);

            previouslyOpenedEdgeWindows.Remove(multiWindowsSession.CurrentWindowHandle);

            // Open a new window
            // The menu item names have changed between Windows 10 and the anniversary update
            // account for both combinations.
            try
            {
                multiWindowsSession.FindElementByAccessibilityId("m_actionsMenuButton").Click();
                multiWindowsSession.FindElementByAccessibilityId("m_newWindow").Click();
            }
            catch (System.InvalidOperationException)
            {
                multiWindowsSession.FindElementByAccessibilityId("ActionsMenuButton").Click();
                multiWindowsSession.FindElementByAccessibilityId("ActionsMenuNewWindow").Click();
            }

            System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds
            var windowHandlesAfter = multiWindowsSession.WindowHandles;

            Assert.IsNotNull(windowHandlesAfter);
            Assert.AreEqual(windowHandlesBefore.Count + 1, windowHandlesAfter.Count);

            // Preserve previously opened Edge Windows by only closing newly opened windows
            List <String> newlyOpenedEdgeWindows = new List <String>(windowHandlesAfter);

            foreach (var previouslyOpenedEdgeWindow in previouslyOpenedEdgeWindows)
            {
                newlyOpenedEdgeWindows.Remove(previouslyOpenedEdgeWindow);
            }

            foreach (var windowHandle in newlyOpenedEdgeWindows)
            {
                multiWindowsSession.SwitchTo().Window(windowHandle);
                multiWindowsSession.Close();
            }

            multiWindowsSession.Quit();
        }
예제 #7
0
        public void SwitchWindows()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId);
            IOSDriver <IOSElement> multiWindowsSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(multiWindowsSession);
            Assert.IsNotNull(multiWindowsSession.SessionId);

            // Preserve previously opened Edge window(s) and only manipulate newly opened windows
            List <String> previouslyOpenedEdgeWindows = new List <String>(multiWindowsSession.WindowHandles);

            previouslyOpenedEdgeWindows.Remove(multiWindowsSession.CurrentWindowHandle);

            // Open a new window
            // The menu item names have changed between Windows 10 and the anniversary update
            // account for both combinations.
            try
            {
                multiWindowsSession.FindElementByAccessibilityId("m_actionsMenuButton").Click();
                multiWindowsSession.FindElementByAccessibilityId("m_newWindow").Click();
            }
            catch (OpenQA.Selenium.NoSuchElementException)
            {
                multiWindowsSession.FindElementByAccessibilityId("ActionsMenuButton").Click();
                multiWindowsSession.FindElementByAccessibilityId("ActionsMenuNewWindow").Click();
            }

            System.Threading.Thread.Sleep(3000); // Sleep for 3 second
            var multipleWindowHandles = multiWindowsSession.WindowHandles;

            Assert.IsTrue(multipleWindowHandles.Count > 1);

            // Preserve previously opened Edge Windows by only operating on newly opened windows
            List <String> newlyOpenedEdgeWindows = new List <String>(multipleWindowHandles);

            foreach (var previouslyOpenedEdgeWindow in previouslyOpenedEdgeWindows)
            {
                newlyOpenedEdgeWindows.Remove(previouslyOpenedEdgeWindow);
            }

            string previousWindowHandle = String.Empty;

            foreach (var windowHandle in newlyOpenedEdgeWindows)
            {
                multiWindowsSession.SwitchTo().Window(windowHandle);
                Assert.AreEqual(multiWindowsSession.CurrentWindowHandle, windowHandle);
                Assert.AreNotEqual(windowHandle, previousWindowHandle);
                previousWindowHandle = windowHandle;
                multiWindowsSession.Close();
            }

            multiWindowsSession.Quit();
        }
예제 #8
0
        public void ErrorNavigateBackNoSuchWindow()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.AlarmClockAppId);
            session = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
            Assert.IsNotNull(session);

            session.Close();
            session.Navigate().Back();
            Assert.Fail("Exception should have been thrown");
        }
예제 #9
0
        public static void TearDown()
        {
            // Cleanup RemoteTouchScreen object if initialized
            touchScreen = null;

            // Close the application and delete the session
            if (session != null)
            {
                try
                {
                    session.Close();
                    var currentHandle = session.CurrentWindowHandle; // This should throw if the window is closed successfully

                    // When the Edge window remains open because of multiple tabs are open, attempt to close modal dialog
                    var closeAllButton = session.FindElementByXPath("//Button[@Name='Close all']");
                    closeAllButton.Click();
                }
                catch { }

                session.Quit();
                session = null;
            }
        }
예제 #10
0
        protected RemoteWebElement GetOrphanedElement(IOSDriver <IOSElement> remoteSession)
        {
            RemoteWebElement orphanedElement = null;

            // Track existing opened Edge window(s) and only manipulate newly opened windows
            var previouslyOpenedEdgeWindows = remoteSession.WindowHandles;
            var originalActiveWindowHandle  = remoteSession.CurrentWindowHandle;

            // Open a new window
            // The menu item names have changed between Windows 10 and the anniversary update
            // account for both combinations.
            try
            {
                remoteSession.FindElementByAccessibilityId("m_actionsMenuButton").Click();
                remoteSession.FindElementByAccessibilityId("m_newWindow").Click();
            }
            catch (OpenQA.Selenium.NoSuchElementException)
            {
                remoteSession.FindElementByAccessibilityId("ActionsMenuButton").Click();
                remoteSession.FindElementByAccessibilityId("ActionsMenuNewWindow").Click();
            }

            System.Threading.Thread.Sleep(3000); // Sleep for 3 second
            var multipleWindowHandles = remoteSession.WindowHandles;

            Assert.IsTrue(multipleWindowHandles.Count == previouslyOpenedEdgeWindows.Count + 1);

            // Ensure we get the newly opened window by removing other previously known windows from the list
            List <String> newlyOpenedEdgeWindows = new List <String>(multipleWindowHandles);

            foreach (var previouslyOpenedEdgeWindow in previouslyOpenedEdgeWindows)
            {
                newlyOpenedEdgeWindows.Remove(previouslyOpenedEdgeWindow);
            }
            Assert.IsTrue(newlyOpenedEdgeWindows.Count == 1);

            // Switch to new window and use the address edit box as orphaned element
            remoteSession.SwitchTo().Window(newlyOpenedEdgeWindows[0]);
            System.Threading.Thread.Sleep(1000); // Sleep for 1 second
            Assert.AreEqual(newlyOpenedEdgeWindows[0], remoteSession.CurrentWindowHandle);
            orphanedElement = remoteSession.FindElementByAccessibilityId("addressEditBox");
            Assert.IsNotNull(orphanedElement);

            // Close the newly opened window and return to previously active window
            remoteSession.Close();
            remoteSession.SwitchTo().Window(originalActiveWindowHandle);
            System.Threading.Thread.Sleep(1000); // Sleep for 1 second

            return(orphanedElement);
        }
예제 #11
0
        public void LaunchClassicApp()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.NotepadAppId);
            IOSDriver <IOSElement> session = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(session);
            Assert.IsNotNull(session.SessionId);

            var originalTitle = session.Title;
            var originalLaunchedWindowHandle = session.CurrentWindowHandle;

            session.LaunchApp();

            Assert.AreEqual(originalTitle, session.Title);
            Assert.AreNotEqual(originalLaunchedWindowHandle, session.CurrentWindowHandle);

            session.Close();
            session.SwitchTo().Window(originalLaunchedWindowHandle);
            session.Close();
            session.Quit();
        }
예제 #12
0
        public void CloseWindowSingleInstanceApplication()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.AlarmClockAppId);
            IOSDriver <IOSElement> singleWindowSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(singleWindowSession);
            Assert.IsNotNull(singleWindowSession.SessionId);

            // Close the application window without deleting the session
            singleWindowSession.Close();
            Assert.IsNotNull(singleWindowSession);
            Assert.IsNotNull(singleWindowSession.SessionId);

            // Delete the session
            singleWindowSession.Quit();
        }
예제 #13
0
        public void PerfectoCloseConnection()
        {
            driver.Close();

            // In case you want to down the report or the report attachments, do it here.
            try
            {
                driver.DownloadReport(DownloadReportTypes.pdf, "C:\\testCS\\reportErrands");
                //    driver.DownloadAttachment(DownloadAttachmentTypes.video, "C:\\test\\report\\video", "flv");
                //    driver.DownloadAttachment(DownloadAttachmentTypes.image, "C:\\test\\report\\images", "jpg");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Error getting test logs: {0}", ex.Message));
            }

            driver.Quit();
        }
예제 #14
0
        public void ErrorNavigateForwardNoSuchWindow()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.AlarmClockAppId);
            session = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
            Assert.IsNotNull(session);

            try
            {
                session.Close();
                session.Navigate().Forward();
                Assert.Fail("Exception should have been thrown");
            }
            catch (System.InvalidOperationException exception)
            {
                Assert.AreEqual("Currently selected window has been closed", exception.Message);
            }
        }
예제 #15
0
        public void GetWindowHandlesModernApp()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId);

            IOSDriver <IOSElement> multiWindowsSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(multiWindowsSession);
            Assert.IsNotNull(multiWindowsSession.SessionId);

            var windowHandlesBefore = multiWindowsSession.WindowHandles;

            Assert.IsNotNull(windowHandlesBefore);
            Assert.IsTrue(windowHandlesBefore.Count > 0);

            // The menu item names have changed between Windows 10 and the anniversary update
            // account for both combinations.
            try
            {
                multiWindowsSession.FindElementByAccessibilityId("m_actionsMenuButton").Click();
                multiWindowsSession.FindElementByAccessibilityId("m_newWindow").Click();
            }
            catch (OpenQA.Selenium.NoSuchElementException)
            {
                multiWindowsSession.FindElementByAccessibilityId("ActionsMenuButton").Click();
                multiWindowsSession.FindElementByAccessibilityId("ActionsMenuNewWindow").Click();
            }

            System.Threading.Thread.Sleep(1000); // Sleep for 1 second
            var windowHandlesAfter = multiWindowsSession.WindowHandles;

            Assert.IsNotNull(windowHandlesAfter);
            Assert.AreEqual(windowHandlesBefore.Count + 1, windowHandlesAfter.Count);

            foreach (var windowHandle in windowHandlesAfter)
            {
                multiWindowsSession.SwitchTo().Window(windowHandle);
                multiWindowsSession.Close();
            }

            multiWindowsSession.Quit();
        }
예제 #16
0
        public void ErrorGetOrientationNoSuchWindow()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.CalculatorAppId);
            session = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
            Assert.IsNotNull(session);
            Assert.IsNotNull(session.SessionId);

            try
            {
                session.Close();
                var orientation = session.Orientation;
                Assert.Fail("Exception should have been thrown");
            }
            catch (System.InvalidOperationException exception)
            {
                Assert.AreEqual("Currently selected window has been closed", exception.Message);
            }

            session.Quit();
            session = null;
        }