Enum Class LocatorFunctions

java.lang.Object
java.lang.Enum<LocatorFunctions>
jp.co.moneyforward.autotest.actions.web.LocatorFunctions
All Implemented Interfaces:
Serializable, Comparable<LocatorFunctions>, Constable

public enum LocatorFunctions extends Enum<LocatorFunctions>

A class that defines function returning utility methods.

Utility methods in this class return a function whose parameter is Locator. Typically, they are used in combination with methods in PageFunctions.

For instance,

  new Click(locatorBySelector("#js-sidebar-opener").andThen(byText(sideMenuItem)))

This finds an element (locator) found by another function PageFunctions#locatorBySelector(String), and then find an element whose text is equal to sideMenuItem.

Functions returned by methods in this class can be pretty printed on a call of toString method call.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Method Summary

    Modifier and Type
    Method
    Description
    static Function<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator>
    byName(String name, boolean lenient)
    Returns a function that finds an element whose name matches name, under a given locator.
    static Function<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator>
    byText(String text)
    Returns a function that finds an element whose text matches text, under a given locator.
    static Function<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator>
    nth(int i)
    A method to compose a function that returns an element at i th position in the element (locator) given as a parameter.
    static Function<com.microsoft.playwright.Locator, String>
    Returns a function which gives a text content of an element given as an argument.
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • values

      public static LocatorFunctions[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static LocatorFunctions valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • nth

      public static Function<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator> nth(int i)
      A method to compose a function that returns an element at i th position in the element (locator) given as a parameter.
      Parameters:
      i - An index of an element to be returned.
      Returns:
      A function that returns i th element in the given locator.
    • byText

      public static Function<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator> byText(String text)

      Returns a function that finds an element whose text matches text, under a given locator.

      The returned function resolves a locator using Locator#getByText(String) method.

      Parameters:
      text - A string to be matched with the text of a given element.
      Returns:
      A function that returns a locator which matches a given text under a locator.
    • byName

      public static Function<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator> byName(String name, boolean lenient)

      Returns a function that finds an element whose name matches name, under a given locator.

      The returned function resolves a locator using the following approach.

      (Locator l) -> l.getByRole(AriaRole.LINK,
                                 new Locator.GetByRoleOptions().setName(name)
                                                               .setExact(!lenient))
      
      Parameters:
      name - A string to be matched with the text of a given element.
      lenient - true - Make the search lenient / false - Make the search strict.
      Returns:
      A function that returns a locator which matches a given text under a locator.
    • textContent

      public static Function<com.microsoft.playwright.Locator, String> textContent()
      Returns a function which gives a text content of an element given as an argument.
      Returns:
      A function which gives a text content of an element given as an argument.