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); }
public override TTControl Control <TTControl>(bool isSearchAllSubElement = false) { TTControl tt = new TTControl(); tt.WrappedElement = FindWebElementFromCurrentWebElement(_thBase + ClassAttribute.Get(typeof(TTControl)), isSearchAllSubElement); return(tt); }
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); }
public virtual TTControl Parent <TTControl>() where TTControl : ControlBase, new() { TTControl tt = new TTControl(); tt.WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::")); return(tt); }
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); }
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); }
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); } }
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); } }
/// <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); } }
/// <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); } }
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); } }
/// <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); }
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); }
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); }
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); }