public WebSearch GetWebSearch() { if (_webSearch == null) { _webSearch = BuildWebSearch(); } return(_webSearch); }
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); }