Class Page.LocatorOptions

  • Enclosing interface:
    Page

    public static class Page.LocatorOptions
    extends Object
    • Field Detail

      • has

        public Locator has
        Narrows down the results of the method to those which contain elements matching this relative locator. For example, article that has text=Playwright matches <article><div>Playwright</div></article>.

        Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the document root. For example, you can find content that has div in <article><content><div>Playwright</div></content></article>. However, looking for content that has article div will fail, because the inner locator must be relative and should not use any elements outside the content.

        Note that outer and inner locators must belong to the same frame. Inner locator must not contain FrameLocators.

      • hasNot

        public Locator hasNot
        Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the outer one. For example, article that does not have div matches <article><span>Playwright</span></article>.

        Note that outer and inner locators must belong to the same frame. Inner locator must not contain FrameLocators.

      • hasNotText

        public Object hasNotText
        Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When passed a [string], matching is case-insensitive and searches for a substring.
      • hasText

        public Object hasText
        Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a [string], matching is case-insensitive and searches for a substring. For example, "Playwright" matches <article><div>Playwright</div></article>.
    • Constructor Detail

      • LocatorOptions

        public LocatorOptions()
    • Method Detail

      • setHas

        public Page.LocatorOptions setHas​(Locator has)
        Narrows down the results of the method to those which contain elements matching this relative locator. For example, article that has text=Playwright matches <article><div>Playwright</div></article>.

        Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the document root. For example, you can find content that has div in <article><content><div>Playwright</div></content></article>. However, looking for content that has article div will fail, because the inner locator must be relative and should not use any elements outside the content.

        Note that outer and inner locators must belong to the same frame. Inner locator must not contain FrameLocators.

      • setHasNot

        public Page.LocatorOptions setHasNot​(Locator hasNot)
        Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the outer one. For example, article that does not have div matches <article><span>Playwright</span></article>.

        Note that outer and inner locators must belong to the same frame. Inner locator must not contain FrameLocators.

      • setHasNotText

        public Page.LocatorOptions setHasNotText​(String hasNotText)
        Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When passed a [string], matching is case-insensitive and searches for a substring.
      • setHasNotText

        public Page.LocatorOptions setHasNotText​(Pattern hasNotText)
        Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When passed a [string], matching is case-insensitive and searches for a substring.
      • setHasText

        public Page.LocatorOptions setHasText​(String hasText)
        Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a [string], matching is case-insensitive and searches for a substring. For example, "Playwright" matches <article><div>Playwright</div></article>.
      • setHasText

        public Page.LocatorOptions setHasText​(Pattern hasText)
        Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a [string], matching is case-insensitive and searches for a substring. For example, "Playwright" matches <article><div>Playwright</div></article>.