protected virtual string BuildXPath(ISearchContext scope, ComponentScopeFindOptions options)
        {
            List <ColumnInfo> columns = TableColumnsInfoCache.GetOrAdd(
                options.Metadata.ParentComponentType,
                _ => GetColumnInfoItems((IWebElement)scope));

            ColumnInfo column = columns.
                                Where(x => options.Match.IsMatch(x.HeaderName, options.Terms)).
                                ElementAtOrDefault(options.Index ?? 0);

            return(column != null?BuildXPathForCell(column, columns) : null);
        }
        public ComponentScopeFindResult Find(ISearchContext scope, ComponentScopeFindOptions options, SearchOptions searchOptions)
        {
            string xPath = BuildXPath(scope, options);

            if (xPath == null)
            {
                if (searchOptions.IsSafely)
                {
                    return(ComponentScopeFindResult.Missing);
                }
                else
                {
                    throw ExceptionFactory.CreateForNoSuchElement(options.GetTermsAsString(), searchContext: scope);
                }
            }

            var xPathOptions = options.Clone();

            xPathOptions.Index = 0;
            xPathOptions.Terms = new[] { xPath };

            return(new SubsequentComponentScopeFindResult(scope, new FindByXPathStrategy(), xPathOptions));
        }