Exemple #1
0
 public WebSearch GetWebSearch()
 {
     if (_webSearch == null)
     {
         _webSearch = BuildWebSearch();
     }
     return(_webSearch);
 }
Exemple #2
0
        private WebSearch BuildWebSearch()
        {
            if (!Locator.IsRelative || Parent == null)
            {
                return(new WebSearch
                {
                    ParentSearch = null,
                    LocatorType = Locator.LocatorType,
                    LocatorValue = Locator.LocatorValue
                });
            }

            var currentSearch = new WebSearch
            {
                LocatorType  = Locator.LocatorType,
                LocatorValue = Locator.LocatorValue
            };
            var parentSearch = Parent.GetWebSearch();

            if (parentSearch.LocatorType == currentSearch.LocatorType &&
                (currentSearch.LocatorType == WebLocatorType.Css ||
                 currentSearch.LocatorType == WebLocatorType.XPath))
            {
                if (currentSearch.LocatorType == WebLocatorType.XPath)
                {
                    currentSearch.LocatorValue = MergeXPath(parentSearch.LocatorValue, currentSearch.LocatorValue);
                }
                else
                {
                    currentSearch.LocatorValue = MergeCss(parentSearch.LocatorValue, currentSearch.LocatorValue);
                }
                currentSearch.ParentSearch = parentSearch.ParentSearch;
            }
            else
            {
                currentSearch.ParentSearch = parentSearch;
            }

            return(currentSearch);
        }