Beispiel #1
0
 ElementInfo IXPath.GetPreviousSibling(ElementInfo EI)
 {
     return(((IXPath)mUIAutomationHelper).GetPreviousSibling(EI));
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 List <ElementInfo> IXPath.GetElementChildren(ElementInfo ElementInfo)
 {
     return(((IXPath)mUIAutomationHelper).GetElementChildren(ElementInfo));
 }
Beispiel #4
0
 List <ElementInfo> IXPath.FindAll(ElementInfo ElementInfo, List <XpathPropertyCondition> conditions)
 {
     return(((IXPath)mUIAutomationHelper).FindAll(ElementInfo, conditions));
 }
Beispiel #5
0
 string IXPath.GetElementProperty(ElementInfo ElementInfo, string PropertyName)
 {
     return(((IXPath)mUIAutomationHelper).GetElementProperty(ElementInfo, PropertyName));
 }
Beispiel #6
0
 ElementInfo IXPath.GetElementParent(ElementInfo ElementInfo)
 {
     return(((IXPath)mUIAutomationHelper).GetElementParent(ElementInfo));
 }
Beispiel #7
0
 XPathHelper IXPath.GetXPathHelper(ElementInfo ei)
 {
     return(((IXPath)mUIAutomationHelper).GetXPathHelper());
 }
Beispiel #8
0
 string IXPath.GetElementTagName(ElementInfo EI)
 {
     return(((IXPath)mUIAutomationHelper).GetElementTagName(EI));
 }
 public string GetElementXpath(ElementInfo EI)
 {
     return(null);
 }