示例#1
0
        public virtual TTControl PrecedingSibling <TTControl>() where TTControl : ControlBase, new()
        {
            TTControl tt = new TTControl();

            tt.WrappedElement = FindWebElementFromCurrentWebElement("/preceding-sibling" + ClassAttribute.Get(typeof(TTControl)).Replace("/", "::") + "[1]");
            return(tt);
        }
示例#2
0
        public virtual TTControl Parent <TTControl>() where TTControl : ControlBase, new()
        {
            TTControl tt = new TTControl();

            tt.WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::"));
            return(tt);
        }
示例#3
0
        public virtual TTControl FollowingSibling <TTControl>() where TTControl : ControlBase, new()
        {
            //e.g: "preceding-sibling::input[@type='radio'][1]"
            TTControl tt = new TTControl();

            tt.WrappedElement = FindWebElementFromCurrentWebElement("/following-sibling" + ClassAttribute.Get(typeof(TTControl)).Replace("/", "::") + "[1]");
            return(tt);
        }
示例#4
0
        public override IList <TTControl> GetControlCollection <TTControl>()
        {
            IList <TTControl> controlCollection = new List <TTControl>();
            int i = 1;

            do
            {
                try
                {
                    var tt = new TTControl();
                    tt.WrappedElement = FindWebElementFromCurrentWebElement(this._trBase + "[" + i.ToString() + "]");
                    if (tt.WrappedElement == null)
                    {
                        break;
                    }
                    controlCollection.Add(tt);
                    i++;
                }
                catch (NotFoundException nx) { break; }
            } while (true);

            return(controlCollection);
        }
示例#5
0
        /// <summary>
        /// For getting the elements if the xpath can get 2 more elements
        /// </summary>
        //public IList<IWebElement> Collection
        //{
        //    get
        //    {
        //        return FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::"));
        //    }
        //}

        public virtual IList <TTControl> GetControlCollection <TTControl>() where TTControl : ControlBase, new()
        {
            IList <TTControl> controlCollection = new List <TTControl>();

            try
            {
                foreach (var item in FindWebElementFromCurrentWebElements(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::")))
                {
                    TTControl tt = new TTControl();
                    tt.WrappedElement = item;
                    controlCollection.Add(tt);
                }
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (NotFoundException)
            {
                Assert.Fail("No Control Found");
            }

            return(controlCollection);
        }