Exemplo n.º 1
0
        public Locator(Frame parent, string selector, LocatorLocatorOptions options = null)
        {
            _frame    = parent;
            _selector = selector;
            _options  = options;

            if (options?.HasTextRegex != null)
            {
                _selector += $" >> :scope:text-matches({options.HasTextRegex.ToString().EscapeWithQuotes("\"")}, {options.HasTextRegex.Options.GetInlineFlags().EscapeWithQuotes("\"")})";
            }
            if (options?.HasTextString != null)
            {
                _selector += $" >> :scope:has-text({options.HasTextString.EscapeWithQuotes("\"")})";
            }

            if (options?.Has != null)
            {
                var has = (Locator)options.Has;
                if (has._frame != _frame)
                {
                    throw new ArgumentException("Inner \"has\" locator must belong to the same frame.");
                }
                _selector += " >> has=" + JsonSerializer.Serialize(has._selector);
            }
        }
Exemplo n.º 2
0
 ILocator ILocator.Locator(string selector, LocatorLocatorOptions options)
 => new Locator(_frame, $"{_selector} >> {selector}", options);