Esempio n. 1
0
        public void NavigateForward_Browser()
        {
            session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private " + CommonTestSettings.EdgeAboutFlagsURL);
            session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);
            Thread.Sleep(TimeSpan.FromSeconds(3));
            var originalTitle = session.Title;

            Assert.AreNotEqual(string.Empty, originalTitle);

            // Navigate to different URLs
            session.FindElementByAccessibilityId("addressEditBox").SendKeys(Keys.Alt + 'd' + Keys.Alt + CommonTestSettings.EdgeAboutTabsURL + Keys.Enter);
            Thread.Sleep(TimeSpan.FromSeconds(2));
            var newTitle = session.Title;

            Assert.AreNotEqual(originalTitle, newTitle);

            // Navigate back to original URL
            session.Navigate().Back();
            Thread.Sleep(TimeSpan.FromSeconds(2));
            Assert.AreNotEqual(newTitle, session.Title);

            // Navigate forward to original URL
            session.Navigate().Forward();
            Thread.Sleep(TimeSpan.FromSeconds(2));
            Assert.AreEqual(newTitle, session.Title);
            EdgeBase.CloseEdge(session);
        }
Esempio n. 2
0
        public void CreateSessionWithArguments_ModernApp()
        {
            // Launch a new Edge window in private mode using appArguments
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId);
            appCapabilities.SetCapability("appArguments", CommonTestSettings.EdgeAboutBlankURL);
            session = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
            Assert.IsNotNull(session);
            Assert.IsNotNull(session.SessionId);
            Thread.Sleep(TimeSpan.FromSeconds(2));
            Assert.IsTrue(session.Title.Contains("Blank page"));
            EdgeBase.CloseEdge(session);
        }
Esempio n. 3
0
        public void CreateSessionWithArguments_ModernApp()
        {
            // Open about:blank page in Microsoft Edge using appArguments
            AppiumOptions appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability("app", CommonTestSettings.EdgeAppId);
            appiumOptions.AddAdditionalCapability("appArguments", CommonTestSettings.EdgeAboutBlankURL);
            session = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appiumOptions);
            Assert.IsNotNull(session);
            Assert.IsNotNull(session.SessionId);
            Thread.Sleep(TimeSpan.FromSeconds(2));
            Assert.IsTrue(session.Title.Contains("Blank page"));
            EdgeBase.CloseEdge(session);
        }
Esempio n. 4
0
        public void GetWindowHandles_ModernApp()
        {
            session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private");
            Assert.IsNotNull(session);

            var windowHandlesBefore = session.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(session.CurrentWindowHandle);

            // Set focus on itself
            session.SwitchTo().Window(session.CurrentWindowHandle);

            // Open a new window in private mode
            session.Keyboard.SendKeys(Keys.Control + Keys.Shift + "p" + Keys.Shift + Keys.Control);
            Thread.Sleep(TimeSpan.FromSeconds(3));
            var windowHandlesAfter = session.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)
            {
                session.SwitchTo().Window(windowHandle);
                EdgeBase.CloseEdge(session);
            }
        }
Esempio n. 5
0
        public void SwitchWindows()
        {
            session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, CommonTestSettings.EdgeAboutBlankURL);
            Assert.IsNotNull(session);

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

            previouslyOpenedEdgeWindows.Remove(session.CurrentWindowHandle);

            // Set focus on itself
            session.SwitchTo().Window(session.CurrentWindowHandle);

            // Open a new window in private mode
            session.Keyboard.SendKeys(Keys.Control + Keys.Shift + "p" + Keys.Shift + Keys.Control);
            Thread.Sleep(TimeSpan.FromSeconds(3));
            var multipleWindowHandles = session.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)
            {
                session.SwitchTo().Window(windowHandle);
                Assert.AreEqual(session.CurrentWindowHandle, windowHandle);
                Assert.AreNotEqual(windowHandle, previousWindowHandle);
                previousWindowHandle = windowHandle;
                EdgeBase.CloseEdge(session);
            }
        }