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

public class Image extends Object
Factory for locating image elements using Playwright selectors.

Uses Playwright's role selectors and attribute matching for image location.

Sample usage:

     Target logo = Image.withAltText("Company Logo");
     Target avatar = Image.withSrc("/images/avatar.png");
     Target productImage = Image.withSrcContaining("product-");
 
  • Method Details

    • withAltText

      public static Target withAltText(String alt)
      Locate an image by its alt text (case-insensitive). Uses Playwright's role selector for semantic image matching.
      Parameters:
      alt - The image's alt text
      Returns:
      A Target for the image element
    • withSrc

      public static Target withSrc(String src)
      Locate an image by its exact src attribute.
      Parameters:
      src - The exact src URL
      Returns:
      A Target for the image element
    • withSrcContaining

      public static Target withSrcContaining(String part)
      Locate an image whose src contains the specified substring.
      Parameters:
      part - The substring to search for in the src attribute
      Returns:
      A Target for the image element
    • locatedBy

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