예제 #1
0
        protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
        {
            string[] conditionalXPathTerms = builder.Options.Terms.
                Where(x => (x.StartsWith("[") && x.EndsWith("]")) || x.StartsWith("@")).
                ToArray();

            string[] conditionalXPathSelectors = conditionalXPathTerms.
                Select(x => x.StartsWith("@") ? x : x.Substring(1, x.Length - 2)).
                ToArray();

            if (conditionalXPathSelectors.Length > 1)
            {
                conditionalXPathSelectors = conditionalXPathSelectors.
                    Select(x => $"({x})").
                    ToArray();
            }

            string conditionalXPath = conditionalXPathSelectors.Any()
                ? builder.WrapWithIndex(x => x.Descendant.ComponentXPath[y => y.JoinOr(conditionalXPathSelectors)])
                : null;

            string[] outerXPathSelectors = builder.Options.Terms.
                Except(conditionalXPathTerms).
                Select(x => acceptableXPathPrefixValues.Any(prefix => x.StartsWith(prefix)) ? x : ".//" + x).
                ToArray();

            string outerXPath = outerXPathSelectors.Any()
                ? builder.WrapWithIndex(x => x._($"({string.Join(" | ", outerXPathSelectors)})")).DescendantOrSelf.ComponentXPath
                : null;

            if (conditionalXPath != null && outerXPath != null)
                return $"(({outerXPath}) | ({conditionalXPath}))";
            else
                return outerXPath ?? conditionalXPath;
        }
예제 #2
0
        protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
        {
            string classCondition = GetClassCondition(options);

            return builder.
                WrapWithIndex(x => x.Descendant.Any[classCondition]).
                DescendantOrSelf.ComponentXPath;
        }
예제 #3
0
        protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
        {
            string idCondition = string.IsNullOrWhiteSpace(options.IdXPathFormat)
                ? builder.TermsConditionOf("id")
                : builder.JoinOr(options.Terms.Select(term => options.IdXPathFormat.FormatWith(term)));

            return builder.WrapWithIndex(x => x.Descendant.Any[idCondition]).DescendantOrSelf.ComponentXPath;
        }
        protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
        {
            string[] conditions = options.Terms.Length > 1
                ? options.Terms.Select(x => $"({x})").ToArray()
                : options.Terms;

            return builder.WrapWithIndex(x => x.Descendant.ComponentXPath[y => y.JoinOr(conditions)]);
        }
            public ComponentScopeLocateResult Find(IWebElement scope, ComponentScopeLocateOptions options, SearchOptions searchOptions)
            {
                ComponentScopeXPathBuilder builder = new ComponentScopeXPathBuilder(options);

                string xPath = builder.
                               WrapWithIndex(x => x.OuterXPath.Any[y => y.TermsConditionOf("id")]).
                               Self.ComponentXPath;

                return(new XPathComponentScopeFindResult(xPath, scope, searchOptions));
            }
예제 #6
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.
            WrapWithIndex(x => x.Descendant.Any[y => y.TermsConditionOf("id")]).
            DescendantOrSelf.ComponentXPath);
 }
예제 #7
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return builder.
         WrapWithIndex(x => x.Descendant.Any[y => y.TermsConditionOf("name")]).
         DescendantOrSelf.ComponentXPath;
 }
예제 #8
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.
            WrapWithIndex(x => x.OuterXPath.ComponentXPath[y => y.TermsConditionOf(attributeName)]));
 }
예제 #9
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.
            WrapWithIndex(x => x.Descendant._("dl/dt")[y => y.TermsConditionOfContent]).
            FollowingSibling._("dd").DescendantOrSelf.ComponentXPath);
 }
예제 #10
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.
            WrapWithIndex(x => x.OuterXPath.ComponentXPath[c => c.Descendant.Any[d => d.TermsConditionOf(_attributeName)]]));
 }
예제 #11
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return builder.
         WrapWithIndex(x => x.Descendant.ComponentXPath[y => y.TermsConditionOfContent]);
 }
예제 #12
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return builder.WrapWithIndex(options.Index.Value, x => x.Descendant.ComponentXPath);
 }
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return builder.
         WrapWithIndex(x => x.Descendant._("fieldset")[y => y._("legend")[z => z.TermsConditionOfContent]]).
         DescendantOrSelf.ComponentXPath;
 }
예제 #14
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.WrapWithIndex(options.Index.Value, x => x.OuterXPath.ComponentXPath));
 }
예제 #15
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.
            WrapWithIndex(x => x.Descendant._("fieldset")[y => y._("legend")[z => z.TermsConditionOfContent]]).
            DescendantOrSelf.ComponentXPath);
 }
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return builder.
         WrapWithIndex(x => x.Descendant._("dl/dt")[y => y.TermsConditionOfContent]).
         FollowingSibling._("dd").DescendantOrSelf.ComponentXPath;
 }
예제 #17
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.
            WrapWithIndex(x => x.OuterXPath._("td").WhereIndex(columnIndex).DescendantOrSelf.ComponentXPath));
 }
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return builder.
         WrapWithIndex(x => x.Descendant._("td").WhereIndex(columnIndex).DescendantOrSelf.ComponentXPath);
 }
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.
            WrapWithIndex(x => x.Descendant.ComponentXPath[y => y.TermsConditionOfContent.Or.TermsConditionOf("value")]));
 }
예제 #20
0
 protected override string Build(ComponentScopeXPathBuilder builder, ComponentScopeLocateOptions options)
 {
     return(builder.
            WrapWithIndex(x => x.OuterXPath.ComponentXPath[y => y.Any[childIndex + 1][z => z.TermsConditionOfContent]]));
 }