Esempio n. 1
0
        ReadOnlyCollection <WindowsElement> QueryWindows(WinQuery query, bool findFirst = false)
        {
            var resultByAccessibilityId = _session.FindElementsByAccessibilityId(query.Marked);
            ReadOnlyCollection <WindowsElement> resultByName = null;

            if (!findFirst || resultByAccessibilityId.Count == 0)
            {
                resultByName = _session.FindElementsByName(query.Marked);
            }

            IEnumerable <WindowsElement> result = resultByAccessibilityId;

            if (resultByName != null)
            {
                result = result.Concat(resultByName);
            }

            // TODO hartez 2017/10/30 09:47:44 Should this be == "*" || == "TextBox"?
            // what about other controls where we might be looking by content? TextBlock?
            if (query.ControlType == "*")
            {
                IEnumerable <WindowsElement> textBoxesByContent =
                    _session.FindElementsByClassName("TextBox").Where(e => e.Text == query.Marked);
                result = result.Concat(textBoxesByContent);
            }

            return(FilterControlType(result, query.ControlType));
        }
Esempio n. 2
0
        public void OneTimeTearDown()
        {
            ReturnToMainPage();
            SwitchToAlarmTab();

            // Delete all created alarms
            var alarmEntries = AlarmClockSession.FindElementsByName("Windows Application Driver Test Alarm");
            foreach (var alarmEntry in alarmEntries)
            {
                AlarmClockSession.Mouse.ContextClick(alarmEntry.Coordinates);
                AlarmClockSession.FindElementByName("Delete").Click();
            }

            AlarmClockSession.Dispose();
            AlarmClockSession = null;
        }
Esempio n. 3
0
        public void AfterEachTest()
        {
            // close "Options" window if it is not closed
            var optionWindow = _driver?.FindElementsByName("Options").FirstOrDefault();

            optionWindow?.FindElementsByName("Cancel").FirstOrDefault()?.Click();
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainScreen"/> class.
        /// </summary>
        /// <param name="vpnSession">VPN session.</param>
        public MainScreen(WindowsDriver <WindowsElement> vpnSession)
        {
            this.titleElement    = Utils.WaitUntilFindElement(vpnSession.FindElementByClassName, "HeroText");
            this.subtitleElement = vpnSession.FindElementByClassName("HeroSubText");
            var settingButtons = vpnSession.FindElementsByName("Settings");

            this.vpnOffSettingButton = settingButtons[0];
            this.vpnOnSettingButton  = settingButtons[1];
            this.vpnSwitch           = vpnSession.FindElementByName("Toggle");
            this.serverListButton    = vpnSession.FindElementByAccessibilityId("ConnectionNavButton");
            this.deviceListButton    = vpnSession.FindElementByName("My devices");
            this.vpnStatus           = vpnSession.FindElementByName("VPN status");
        }
Esempio n. 5
0
        ReadOnlyCollection <WindowsElement> QueryWindows(WinQuery query)
        {
            var resultByName            = _session.FindElementsByName(query.Marked);
            var resultByAccessibilityId = _session.FindElementsByAccessibilityId(query.Marked);

            var result = resultByName
                         .Concat(resultByAccessibilityId);

            if (query.ControlType == "*")
            {
                var textBoxesByContent = _session.FindElementsByClassName("TextBox").Where(e => e.Text == query.Marked);
                result = result.Concat(textBoxesByContent);
            }

            return(FilterControlType(result, query.ControlType));
        }
Esempio n. 6
0
        protected AppiumWebElement SearchWindowsElement(WindowsDriver <AppiumWindowsElement> desktopSession, AppiumWebElement parentElement, WindowsElementSearchSpec windowsElementSearchSpec, IList <string> log)
        {
            log.Clear();
            var elements = new List <AppiumWebElement>();

            if (desktopSession != null && !string.IsNullOrWhiteSpace(windowsElementSearchSpec.Name))
            {
                elements = desktopSession.FindElementsByName(windowsElementSearchSpec.Name).Cast <AppiumWebElement>().ToList();
            }
            else if (desktopSession != null && windowsElementSearchSpec.ClassNames.Any())
            {
                windowsElementSearchSpec.ClassNames.ForEach(n => elements.AddRange(desktopSession.FindElementsByClassName(n)));
            }
            else if (!string.IsNullOrWhiteSpace(windowsElementSearchSpec.Name))
            {
                elements = parentElement.FindElementsByName(windowsElementSearchSpec.Name).ToList();
            }
            else if (windowsElementSearchSpec.ClassNames.Any())
            {
                windowsElementSearchSpec.ClassNames.ForEach(n => elements.AddRange(parentElement.FindElementsByClassName(n)));
            }
            else
            {
                throw new ArgumentException($"Invalid {nameof(WindowsElementSearchSpec)}, name or class name is required");
            }
            var reverseSearchSpecs = elements.Select(e => new WindowsElementSearchSpec(e));

            log.Add(elements.Any()
                ? $"[{windowsElementSearchSpec}] applied to root element resulted in {elements.Count} elements: {string.Join(", ", reverseSearchSpecs)}"
                : $"[{windowsElementSearchSpec}] applied to root element did not yield any results");

            foreach (var element in elements)
            {
                if (!DoesElementMatchSearchSpec(element, windowsElementSearchSpec, 0, log, "", out var elementOrMatchingChildElement))
                {
                    continue;
                }

                if (elementOrMatchingChildElement == null)
                {
                    throw new Exception("Element matches search specification, but no element is returned");
                }
                return(elementOrMatchingChildElement);
            }
            return(null);
        }
Esempio n. 7
0
        public int isContactSearchFormExists()
        {
            var msg = driver.FindElementsByName("Contact Search").Count();

            return(msg);
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            WindowsDriver <WindowsElement> sessionJpt;
            AppiumOptions appOptions = new AppiumOptions();

            appOptions.AddAdditionalCapability("app", @"C:\Program Files\TechnoStar\Jupiter-Pre_5.0\DCAD_main.exe");

            sessionJpt = new WindowsDriver <WindowsElement>(
                new Uri("http://127.0.0.1:4723"),
                appOptions
                );

            // IMPORT:

            /* var importCad = sessionJpt.FindElementByName("Import CAD");
             * action.MoveToElement(importCad);
             * action.MoveToElement(importCad, importCad.Size.Width/2, importCad.Size.Height/3 + 40).Click().Perform();
             *
             * sessionJpt.FindElementByName("VRML").Click();
             *
             * action.SendKeys(@"V:\Technologies\CS\UIAutomation\ScenarioTestDocs\SampleData\Block\Block.wrl");
             * action.SendKeys(Keys.Enter);
             * action.Perform();
             *
             * sessionJpt.FindElementByName("OK").Click();
             */
            sessionJpt.FindElementByName("Open...").Click();
            System.Threading.Thread.Sleep(3000);
            Actions action = new Actions(sessionJpt);

            action.SendKeys(@"V:\Technologies\CS\UIAutomation\ScenarioTestDocs\SampleData\Block\Block.jtdb");
            action.SendKeys(Keys.Enter);
            action.Perform();


            sessionJpt.FindElementByName("Mesh Cleanup").Click();
            sessionJpt.FindElementByName("Free Edges").Click();

            var allParts = sessionJpt.FindElementByName("All Parts");

            action = new Actions(sessionJpt);
            action.MoveToElement(allParts);
            action.Click();
            // Right Click
            action.ContextClick();
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            sessionJpt.FindElementByName("Apply").Click();

            action = new Actions(sessionJpt);
            action.SendKeys(Keys.Enter);
            action.Perform();

            sessionJpt.FindElementByName("Cancel").Click();
            sessionJpt.FindElementByName("Close Gaps").Click();

            action = new Actions(sessionJpt);
            action.MoveToElement(allParts);
            action.Click();
            action.ContextClick();
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            typeInBox(1001, 0.01, sessionJpt);

            sessionJpt.FindElementByName("OK").Click();


            sessionJpt.FindElementByName("Geometry").Click();
            sessionJpt.FindElementByName("Merge Entities").Click();
            action = new Actions(sessionJpt);
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            sessionJpt.FindElementByName("Home").Click();
            WindowsElement find = sessionJpt.FindElementByName("Find");

            action = new Actions(sessionJpt);
            action.MoveToElement(find);
            action.MoveToElement(find, find.Size.Width / 2, find.Size.Height / 3 + 40).Click();
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            int[] faceIdArr = { 321, 317, 316, 320, 333, 343, 354, 353, 342, 332, 328, 340, 350, 351, 341, 329 };

            WindowsElement idBox = sessionJpt.FindElementByAccessibilityId("1582");

            foreach (int faceId in faceIdArr)
            {
                InputId(faceId, idBox, action, sessionJpt, find);
            }

            sessionJpt.FindElementByName("OK").Click();

            sessionJpt.FindElementByName("Meshing").Click();

            WindowsElement localSettings = sessionJpt.FindElementByName("Local Settings");

            action = new Actions(sessionJpt);
            action.MoveToElement(localSettings);
            action.MoveToElement(localSettings, localSettings.Size.Width / 2 - 50, localSettings.Size.Height / 2)
            .Click();
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            action = new Actions(sessionJpt);
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            sessionJpt.FindElementByName("Home").Click();

            InputId(708, idBox, action, sessionJpt, find);
            InputId(698, idBox, action, sessionJpt, find);

            sessionJpt.FindElementByName("Mesh Size").Click();
            typeInBox(1006, 4, sessionJpt);
            typeInBox(1007, 1, sessionJpt);
            typeInBox(1008, 8, sessionJpt);

            sessionJpt.FindElementByName("Apply").Click();

            InputId(1, idBox, action, sessionJpt, find);
            InputId(2, idBox, action, sessionJpt, find);
            InputId(3, idBox, action, sessionJpt, find);
            InputId(4, idBox, action, sessionJpt, find);

            sessionJpt.FindElementByName("Mesh Size").Click();
            sessionJpt.FindElementByName("Keep Entity").Click();
            sessionJpt.FindElementByName("OK").Click();


            sessionJpt.FindElementByName("Meshing").Click();
            sessionJpt.FindElementByName("Surface Meshing").Click();
            typeInBox(1001, 15, sessionJpt);
            typeInBox(1002, 1, sessionJpt);
            typeInBox(1003, 30, sessionJpt);
            typeInBox(1004, 1, sessionJpt);

            sessionJpt.FindElementByName("OK").Click();

            /*
             * System.Threading.Thread.Sleep(10000);
             *
             * WindowsElement completeDialog = sessionJpt.FindElementByName("Meshing Surf Meshing");
             * action = new Actions(sessionJpt);
             * action.MoveToElement(completeDialog);
             * action.MoveToElement(completeDialog, completeDialog.Size.Width / 2 + 70,
             *  completeDialog.Size.Height / 2 + 60)
             *  .Click();
             * action.Perform();
             */

            //sessionJpt.FindElementByName("OK").Click();
            System.Threading.Thread.Sleep(20000);
            var okBtns = sessionJpt.FindElementsByName("OK");

            if (okBtns[0].Location.Y < okBtns[1].Location.Y)
            {
                okBtns[0].Click();
            }
            else
            {
                okBtns[1].Click();
            }
            Debug.WriteLine(okBtns.Count);

            /*
             * foreach (WindowsElement okBtn in okBtns)
             * {
             *  Debug.WriteLine(okBtn.Location.Y);
             * }
             */
        }
 public void CheckUiExist()
 {
     Assert.NotNull(calcSession.FindElementsByName("Calculator"), "Calc does NOT exist");
 }
Esempio n. 10
0
 public override IEnumerable <WindowsElement> FindAllElements(WindowsDriver <WindowsElement> searchContext)
 {
     return(searchContext.FindElementsByName(Value));
 }