Enum Class LocatorFunctions
- All Implemented Interfaces:
Serializable
,Comparable<LocatorFunctions>
,Constable
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 TypeMethodDescriptionstatic Function
<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator> Returns a function that finds an element whose name matchesname
, under a givenlocator
.static Function
<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator> Returns a function that finds an element whose text matchestext
, under a givenlocator
.static Function
<com.microsoft.playwright.Locator, com.microsoft.playwright.Locator> nth
(int i) A method to compose a function that returns an element ati
th position in the element (locator) given as a parameter.Returns a function which gives a text content of an element given as an argument.static LocatorFunctions
Returns the enum constant of this class with the specified name.static LocatorFunctions[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Method Details
-
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
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 nameNullPointerException
- 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 ati
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 givenlocator
.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 givenlocator
.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
-