public WebSearchInfoModel(WebSearchInfo webSearchInfo = null)
 {
     if (webSearchInfo != null)
     {
         LocatorType  = webSearchInfo.LocatorType;
         LocatorValue = webSearchInfo.LocatorValue;
         if (webSearchInfo.ParentSearch != null)
         {
             ParentSearch = WebElementsViewModelsHelper.CreateWebSearchModelFromInfo(webSearchInfo.ParentSearch);
         }
     }
 }
        public static WebSearchInfoModel CreateWebSearchModelFromInfo(WebSearchInfo webSearchInfo)
        {
            WebSearchInfoModel model = null;

            if (webSearchInfo is FrameWebSearchInfo fwsi)
            {
                model = new FrameWebSearchInfoViewModel(fwsi);
            }
            else
            {
                model = new WebSearchInfoModel(webSearchInfo);
            }

            return(model);
        }
Esempio n. 3
0
        private By GetBy(WebSearchInfo webSearch)
        {
            switch (webSearch.LocatorType)
            {
            case WebLocatorType.XPath:
                return(By.XPath(webSearch.LocatorValue));

            case WebLocatorType.Css:
                return(By.CssSelector(webSearch.LocatorValue));

            case WebLocatorType.Id:
                return(By.Id(webSearch.LocatorValue));

            default:
                throw new NotImplementedException($"Unknown locator type {webSearch.LocatorType}");
            }
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length != 2)
            {
                return(null);
            }
            if (!(values[1] is WebElementInfoViewModel webElement))
            {
                return(null);
            }

            WebSearchInfo ws = null;

            try
            {
                ws = webElement.GetWebSearch();
            }
            catch (Exception ex)
            {
                ws = new WebSearchInfo
                {
                    LocatorValue = $"Error: {ex.Message}"
                };
            }

            var wsModel = WebElementsViewModelsHelper.CreateWebSearchModelFromInfo(ws);

            var list = new List <WebSearchInfoModel>();

            var cur = wsModel;

            while (cur != null)
            {
                list.Add(cur);
                cur = cur.ParentSearch;
            }

            list.Reverse();

            return(list);
        }