예제 #1
0
        public void ComplexEnumStringsInts()
        {
            //Arrange
            int       vala  = 123;
            int       valb  = 545;
            string    valsa = "String1";
            string    valsb = "ZXCVFDSW";
            eLocateBy loc   = eLocateBy.ByName;

            PayLoad pl = new PayLoad("ComplexEnumStringsInts");

            pl.AddValue(vala);
            pl.AddValue(valb);
            pl.AddValue(valsa);
            pl.AddValue(valsb);
            pl.AddEnumValue(loc);
            pl.ClosePackage();

            // Act
            byte[] b = pl.GetPackage();

            PayLoad pl2    = new PayLoad(b);
            int     vala2  = pl2.GetValueInt();
            int     valb2  = pl2.GetValueInt();
            string  valsa2 = pl2.GetValueString();
            string  valsb2 = pl2.GetValueString();
            string  Loc2   = pl2.GetValueEnum();

            //Assert
            Assert.AreEqual(vala, vala2);
            Assert.AreEqual(valb, valb2);
            Assert.AreEqual(valsa, valsa2);
            Assert.AreEqual(valsb, valsb2);
            Assert.AreEqual(loc.ToString(), Loc2);
        }
예제 #2
0
        public override object FindElementByLocator(eLocateBy eLocatorType, string LocateValue)
        {
            AutomationElement CurAE = null;

            switch (eLocatorType)
            {
            case eLocateBy.ByName:
                ConditionBase CurCond2 = new PropertyCondition(AutomationObjectIds.NameProperty, LocateValue);
                CurAE = this.CurrentWindow.FindFirst(TreeScope.Subtree, CurCond2);

                //For old compativity where Name was the text we fail over to search by Text, PB Only, it is slower as it scan the tree and call win api to get the text
                if (Object.ReferenceEquals(CurAE, null) && mPlatform == ePlatform.PowerBuilder)
                {
                }
                break;

            case eLocateBy.ByXPath:
                UIAElementInfo e = (UIAElementInfo)mXPathHelper.GetElementByXpath(LocateValue);
                CurAE = (AutomationElement)e.ElementObject;
                break;

            case eLocateBy.ByAutomationID:
                ConditionBase CurCond3 = new PropertyCondition(val.AutomationId, LocateValue);
                CurAE = CurrentWindow.FindFirst(TreeScope.Subtree, CurCond3);
                break;

            case eLocateBy.ByClassName:
                ConditionBase CurCond4 = new PropertyCondition(val.ClassName, LocateValue);
                CurAE = CurrentWindow.FindFirst(TreeScope.Subtree, CurCond4);
                break;

            case eLocateBy.ByXY:
                double   xx = 0, yy = 0;
                bool     statusFlag;
                string[] str = LocateValue.Split(',');
                xx = Convert.ToDouble(str[0]);
                yy = Convert.ToDouble(str[1]);
                xx = xx + Convert.ToInt32(CurrentWindow.Properties.BoundingRectangle.Value.X);
                yy = yy + Convert.ToInt32(CurrentWindow.Properties.BoundingRectangle.Value.Y);
                System.Windows.Point point = new System.Windows.Point(xx, yy);
                statusFlag = WinAPIAutomation.SetForeGroundWindow(CurrentWindow.Properties.ProcessId);
                if (statusFlag == false)
                {
                }
                CurAE = CurrentWindow.Automation.FromPoint(point);
                break;

            default:
                throw new Exception("Locator not implement - " + eLocatorType.ToString());
            }
            return(CurAE);
        }