java.lang.Object
net.serenitybdd.screenplay.playwright.ui.Link

public class Link extends Object
Factory for locating link (anchor) elements using Playwright selectors.

Uses Playwright's role selectors and CSS pseudo-classes for flexible link location.

Sample usage:

     Target homeLink = Link.withText("Home");
     Target learnMoreLink = Link.containingText("Learn more");
     Target helpLink = Link.withTitle("Get help");
 
  • Method Details

    • withText

      public static Target withText(String text)
      Locate a link by its exact accessible name (case-insensitive). Uses Playwright's role selector for semantic link matching.
      Parameters:
      text - The link's accessible name or text content
      Returns:
      A Target for the link element
    • containingText

      public static Target containingText(String text)
      Locate a link containing the specified text (partial match).
      Parameters:
      text - The text to search for within the link
      Returns:
      A Target for the link element
    • withTitle

      public static Target withTitle(String title)
      Locate a link by its title attribute (case-insensitive).
      Parameters:
      title - The title attribute value
      Returns:
      A Target for the link element
    • locatedBy

      public static Target locatedBy(String selector)
      Locate a link using a custom Playwright selector.
      Parameters:
      selector - A valid Playwright selector
      Returns:
      A Target for the link element