ElementInfo IXPath.GetPreviousSibling(ElementInfo EI) { return(((IXPath)mUIAutomationHelper).GetPreviousSibling(EI)); }
public string GetElementRelXPath(ElementInfo elemInfo) { var relxpath = ""; string xpath = elemInfo.XPath; List <object> elemsList = null; try { while (relxpath.IndexOf("//") == -1 && elemInfo.ElementObject != null) { string id = mDriver.GetElementID(elemInfo); if (!string.IsNullOrEmpty(id)) { relxpath = xpath.Replace(elemInfo.XPath, "//" + mDriver.GetElementTagName(elemInfo).ToLower() + "[@id='" + id + "']"); elemsList = mDriver.GetAllElementsByLocator(eLocateBy.ByRelXPath, relxpath); if (elemsList == null || (elemsList != null && elemsList.Count() < 2)) { continue; } } string name = Convert.ToString(mDriver.GetElementProperty(elemInfo, "name")); if (!string.IsNullOrEmpty(name)) { if (relxpath == "") { relxpath = xpath.Replace(elemInfo.XPath, "//" + mDriver.GetElementTagName(elemInfo).ToLower() + "[@name='" + name + "']"); } else { relxpath = xpath.Replace(elemInfo.XPath, "//" + mDriver.GetElementTagName(elemInfo).ToLower() + "[@id='" + id + "' and @name ='" + name + "']"); } elemsList = mDriver.GetAllElementsByLocator(eLocateBy.ByRelXPath, relxpath); if (elemsList == null || (elemsList != null && elemsList.Count() < 2)) { continue; } } if (relxpath.IndexOf("//") != -1 && elemsList != null) { string path = relxpath; for (int i = 1; i <= elemsList.Count(); i++) { relxpath = "(" + path + ")[" + i + "]"; List <object> newElem = mDriver.GetAllElementsByLocator(eLocateBy.ByRelXPath, relxpath); if (newElem != null && newElem.Count() > 0 && newElem[0].Equals(elemInfo.ElementObject)) { break; } } continue; } if (relxpath == "") { elemInfo = mDriver.GetElementParent(elemInfo); if (elemInfo is HTMLElementInfo && !string.IsNullOrEmpty(((HTMLElementInfo)elemInfo).RelXpath)) { relxpath = xpath.Replace(elemInfo.XPath, ((HTMLElementInfo)elemInfo).RelXpath); break; } } } } catch (Exception e) { relxpath = xpath; Reporter.ToLog(eLogLevel.DEBUG, "Exception in GetElementRelXPath ::", e); } if (relxpath == "") { relxpath = xpath; } return(relxpath); }
List <ElementInfo> IXPath.GetElementChildren(ElementInfo ElementInfo) { return(((IXPath)mUIAutomationHelper).GetElementChildren(ElementInfo)); }
List <ElementInfo> IXPath.FindAll(ElementInfo ElementInfo, List <XpathPropertyCondition> conditions) { return(((IXPath)mUIAutomationHelper).FindAll(ElementInfo, conditions)); }
string IXPath.GetElementProperty(ElementInfo ElementInfo, string PropertyName) { return(((IXPath)mUIAutomationHelper).GetElementProperty(ElementInfo, PropertyName)); }
ElementInfo IXPath.GetElementParent(ElementInfo ElementInfo) { return(((IXPath)mUIAutomationHelper).GetElementParent(ElementInfo)); }
XPathHelper IXPath.GetXPathHelper(ElementInfo ei) { return(((IXPath)mUIAutomationHelper).GetXPathHelper()); }
string IXPath.GetElementTagName(ElementInfo EI) { return(((IXPath)mUIAutomationHelper).GetElementTagName(EI)); }
public string GetElementXpath(ElementInfo EI) { return(null); }