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