Enum Class PageFunctions

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

public enum PageFunctions extends Enum<PageFunctions>

A utility class to handle Page object.

Methods in this class return a function whose parameter is a Page object of Playwright.

It is common to see a situation, where a single method call to a page object cannot determine a single element to be returned. In such a case, you can use functions provided by LocatorFunctions in combination.

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

This is an example to find a locator, which is specified by a text sideMenuItem under a locator specified by a selector string #js-sidebar-opener.

In general methods in this class are named in the following manner.

{typeName}By{SelectionMethod}

typeName can be, for instance, locator, linkLocator. SelectionMethod can be Name, Text, Label, Selector, etc.

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.Page, com.microsoft.playwright.Locator>
    Returns a function that resolve a locator to a button object in a Page, whose name is equal to name.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    Returns a function that gives a locator of a link whose text equals to a given text inside a Page.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    Returns a function that resolves a locator specified by name in a given Page object.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    linkLocatorByName(String name, boolean lenient)
    Returns a function that resolves a given name to a locator of a link whose name matches with it.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    Returns a function that gives a locator of a link whose text contains a given text inside a Page.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    linkLocatorByText(String text, boolean lenient)
     
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    Returns a function that resolves a locator whose label matches with label in a given Page.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    locatorByLabel(String label, boolean lenient)
    Returns a function that resolves a locator whose label matches with label in a given Page.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    Returns a function that resolves a locator whose placeholder is placeholder.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    Returns a function that resolves a locator specified by selector in a given Page.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    Returns a function that resolves a locator whose text contains text in a given page.
    static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator>
    locatorByText(String text, boolean lenient)
    Returns a function that resolves a locator which matches text in a given Page object.
    static Function<com.microsoft.playwright.Page, String>
    Returns a function that gives a title of the given page.
    Returns the enum constant of this class with the specified name.
    static PageFunctions[]
    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 PageFunctions[] 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 PageFunctions 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
    • linkLocatorByName

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> linkLocatorByName(String name)

      Returns a function that resolves a locator specified by name in a given Page object.

      This is a shorthand method for linkLocatorByName(name, false).

      Parameters:
      name - A name of a link.
      Returns:
      A function that resolves a locator specified by name in a given Page object.
    • linkLocatorByName

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> linkLocatorByName(String name, boolean lenient)
      Returns a function that resolves a given name to a locator of a link whose name matches with it.
      Parameters:
      name - A name of a link locator to be matched.
      lenient - true - partial match / false - exact match.
      Returns:
      A function that resolves a given name to a locator of a link whose name matches with it.
    • locatorByText

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> locatorByText(String text)
      Returns a function that resolves a locator whose text contains text in a given page.
      Parameters:
      text - A text to be contained by the matching locator.
      Returns:
      a function that resolves a locator whose text contains text in a given page.
    • locatorByText

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> locatorByText(String text, boolean lenient)

      Returns a function that resolves a locator which matches text in a given Page object. If lenient is true, a locator whose text contains it is considered matched. If lenient is false, a locator whose text equals to text is considered matched.

      The match is done by:

      Page#GetByText(text, new Page.GetByTextOptions().setExact(!lenient)

      Parameters:
      text - A text to be matched.
      lenient - true - lenient / false - strict.
      Returns:
      A function that resolves a locator which matches text in a given Page object.
    • buttonLocatorByName

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> buttonLocatorByName(String name)
      Returns a function that resolve a locator to a button object in a Page, whose name is equal to name.
      Parameters:
      name - A string to be matched with a locator's name.
      Returns:
      A function that resolve a locator to a button object in a Page, whose name is equal to name.
    • locatorByLabel

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> locatorByLabel(String label)
      Returns a function that resolves a locator whose label matches with label in a given Page.
      Parameters:
      label - A string to be matched with a label of a locator.
      Returns:
      A function that resolves a locator whose label matches with label.
    • locatorByLabel

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> locatorByLabel(String label, boolean lenient)

      Returns a function that resolves a locator whose label matches with label in a given Page.

      The resolution is done by a following method-call.

      Page#getByLabel(label, new Page.GetByLabelOptions().setExact(!lenient))
      

      If lenientis set to true, a locator whose label contains label will be considered matched. If it is false, a locator whose label is equal to label will be considered matched.

      Parameters:
      label - A string to be matched with a label of a locator.
      lenient - true - lenient / false - strict.
      Returns:
      a function that resolves a locator whose label matches with label in a given Page.
    • locatorByPlaceholder

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> locatorByPlaceholder(String placeholder)
      Returns a function that resolves a locator whose placeholder is placeholder.
      Parameters:
      placeholder - A string to be matched with a locator's placeholder.
      Returns:
      A function that resolves a locator whose placeholder is placeholder.
    • locatorBySelector

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> locatorBySelector(String selector)
      Returns a function that resolves a locator specified by selector in a given Page.
      Parameters:
      selector - A selector string that specifies a locator.
      Returns:
      A function that resolves a locator specified by selector in a given Page.
    • linkLocatorByText

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> linkLocatorByText(String text)
      Returns a function that gives a locator of a link whose text contains a given text inside a Page.
      Parameters:
      text - A string to be matched with a text of a link in a given Page. @return A function that gives a locator of a link whose text matches a given textinside aPage`.
    • linkLocatorByExactText

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> linkLocatorByExactText(String text)
      Returns a function that gives a locator of a link whose text equals to a given text inside a Page.
      Parameters:
      text - A string to be matched with a text of a link in a given Page. @return A function that gives a locator of a link whose text equals to a given textinside aPage`.
    • toTitle

      public static Function<com.microsoft.playwright.Page, String> toTitle()
      Returns a function that gives a title of the given page.
      Returns:
      A function that gives a title of the given page.
    • linkLocatorByText

      public static Function<com.microsoft.playwright.Page, com.microsoft.playwright.Locator> linkLocatorByText(String text, boolean lenient)