コード例 #1
0
ファイル: Locator.cs プロジェクト: microsoft/playwright-sharp
        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);
            }
        }
コード例 #2
0
ファイル: Locator.cs プロジェクト: microsoft/playwright-sharp
 ILocator ILocator.Locator(string selector, LocatorLocatorOptions options)
 => new Locator(_frame, $"{_selector} >> {selector}", options);