Exemple #1
0
        public virtual TTControl ControlAttribute <TTControl>(string name, string value) where TTControl : ControlBase, new()
        {
            TTControl tt = new TTControl();

            tt.WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)) + string.Format("[@{0}='{1}']", name, value));
            return(tt);
        }
        public override TTControl ControlText <TTControl>(string text, bool isSearchAllSubElement = false)
        {
            TTControl tt = new TTControl();

            tt.WrappedElement = FindWebElementFromCurrentWebElement("/div" + ClassAttribute.Get(typeof(TTControl)) + string.Format("[text()='{0}']", text), isSearchAllSubElement);
            return(tt);
        }
Exemple #3
0
        public override TTControl Control <TTControl>(bool isSearchAllSubElement = false)
        {
            TTControl tt = new TTControl();

            tt.WrappedElement = FindWebElementFromCurrentWebElement(_thBase + ClassAttribute.Get(typeof(TTControl)), isSearchAllSubElement);
            return(tt);
        }
Exemple #4
0
        public virtual TTControl Control <TTControl>(bool isSearchAllSubElement = false) where TTControl : ControlBase, new()
        {
            TTControl tt = new TTControl();

            tt.WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)), isSearchAllSubElement);
            return(tt);
        }
Exemple #5
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);
        }
Exemple #6
0
 public virtual IList <IWebElement> GetElementCollection <TTControl>() where TTControl : ControlBase, new()
 {
     try
     {
         return(FindWebElementFromCurrentWebElements(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::")));
     }
     catch (NotFoundException)
     {
         Assert.Fail("No Control Found");
     }
     return(null);
 }
Exemple #7
0
        public virtual IList <TTControl> ControlAttributeStartWithCollection <TTControl>(string name, string value, bool isSearchAllSubElement = false) where TTControl : ControlBase, new()
        {
            IList <TTControl> controlCollection = new List <TTControl>();

            foreach (var item in FindWebElementFromCurrentWebElements(ClassAttribute.Get(typeof(TTControl)) + string.Format("[starts-with(@{0},'{1}')]", name, value), isSearchAllSubElement))
            {
                TTControl tt = new TTControl();
                tt.WrappedElement = item;
                controlCollection.Add(tt);
            }

            return(controlCollection);
        }
Exemple #8
0
 public override TTControl ControlText <TTControl>(string text, bool isSearchAllSubElement = false)
 {
     if (typeof(TTControl) == this.GetType())
     {
         WrappedElement = FindWebElementFromCurrentWebElement(_thBase + string.Format("[text()='{0}']", text), isSearchAllSubElement);
         return(this as TTControl);
     }
     else
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(_thBase + ClassAttribute.Get(typeof(TTControl)) + string.Format("[text()='{0}']", text), isSearchAllSubElement);
         return(tt);
     }
 }
Exemple #9
0
 public virtual TTControl ControlTextFuzzy <TTControl>(string text, bool isSearchAllSubElement = false) where TTControl : ControlBase, new()
 {
     if (typeof(TTControl) == this.GetType())
     {
         WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::") + string.Format("[contains(text(),'{0}')]", text), isSearchAllSubElement);
         return(this as TTControl);
     }
     else
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(text(),'{0}')]", text), isSearchAllSubElement);
         return(tt);
     }
 }
Exemple #10
0
 /// <summary>
 /// Select Cell by Attrubute (Some controls like row and table whose args of constructor is different from normal controls need to override this function)
 /// </summary>
 /// <typeparam name="TTControl">Sub Control Type</typeparam>
 /// <param name="name">Attribute Name</param>
 /// <param name="value">Attribute value</param>
 /// <returns></returns>
 public virtual TTControl ControlAttributeFuzzy <TTControl>(string name, string value) where TTControl : ControlBase, new()
 {
     if (typeof(TTControl) == this.GetType())
     {
         WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::") + string.Format("[contains(@{0},'{1}')]", name, value));
         return(this as TTControl);
     }
     else
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(@{0},'{1}')]", name, value));
         return(tt);
     }
 }
Exemple #11
0
 /// <summary>
 /// Select Cell by Attrubute (Some controls like row and table whose args of constructor is different from normal controls need to override this function)
 /// </summary>
 /// <typeparam name="TTControl">Sub Control Type</typeparam>
 /// <param name="name">Attribute Name</param>
 /// <param name="value">Attribute value</param>
 /// <returns></returns>
 public override TTControl ControlAttributeFuzzy <TTControl>(string name, string value)
 {
     if (typeof(TTControl) == this.GetType())
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(_trBase + string.Format("[contains(@{0},'{1}')]", name, value));
         return(tt);
     }
     else
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(_trBase + ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(@{0},'{1}')]", name, value));
         return(tt);
     }
 }
Exemple #12
0
 public RadioItem GetRadioItemByText <TTControl>(string text) where TTControl : ControlBase, new()
 {
     if (base.WrappedElement == null)
     {
         var tt = new TTControl();
         tt.WrappedElement = tt.CurrentBrowser.WebDriver.FindElement(By.XPath("/" + string.Format("{0}", ClassAttribute.Get(typeof(TTControl)))));
         var t = new RadioItem(By.XPath("/" + ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(text(),'{0}')]", text)));
         return(t);
     }
     else
     {
         var tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(string.Format("/{0}", ClassAttribute.Get(typeof(TTControl))));
         var t = tt.ControlTextFuzzy <TTControl>(text).PrecedingSibling <RadioItem>();
         return(t);
     }
 }
Exemple #13
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);
        }
Exemple #14
0
        public virtual IList <TTControl> ControlTextFuzzyCollection <TTControl>(string text, bool isSearchAllSubElement = false) where TTControl : ControlBase, new()
        {
            IList <TTControl> controlCollection = new List <TTControl>();

            if (typeof(TTControl) == this.GetType())
            {
                foreach (var item in FindWebElementFromCurrentWebElements(string.Format("[contains(text(),'{0}')]", text), isSearchAllSubElement))
                {
                    TTControl tt = new TTControl();
                    tt.WrappedElement = item;
                    controlCollection.Add(tt);
                }
            }
            else
            {
                foreach (var item in FindWebElementFromCurrentWebElements(ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(text(),'{0}')]", text), isSearchAllSubElement))
                {
                    TTControl tt = new TTControl();
                    tt.WrappedElement = item;
                    controlCollection.Add(tt);
                }
            }
            return(controlCollection);
        }
Exemple #15
0
        public virtual TTControl FollowingSibling <TTControl>(int position) 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("/", "::") + "[" + position + "]");
            return(tt);
        }
Exemple #16
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);
        }