To learn more about using LeanFT for Selenium, see LeanFT for Selenium.

By

LFTForSelenium. By

new By()

Contains all LeanFT for Selenium By methods for locating elements.

Methods

any(bys)

Returns a function that locates and returns elements that match at least one of the locators provided (OR).
Parameters:
Name Type Description
bys Array.<Object> At least one of these locators are used to identify the elements.
Returns:
A function that locates and returns elements that match at least one of the provided locators.

attributes(attributes)

Returns a function that locates and returns elements according to the provided attributes. You can also use regular expressions.
Parameters:
Name Type Description
attributes Object The attributes by which the elements are identified.
Returns:
A function that locates and returns elements with matching attributes.

chained(bys)

Returns a function that locates and returns elements by using locators that describe the elements and their ancestors (higher level elements).
Parameters:
Name Type Description
bys Array.<Object> A list of locators, each representing a level in the hierarchy, starting with the highest level.
Returns:
A function that locates and returns elements nested within the hierarchy that contains the provided locators.

className(className)

Returns a function that locates and returns elements with the provided className parameter. The LeanFT locator is used only when the value passed is a regular expression. Otherwise, the Selenium locator is used.
Parameters:
Name Type Description
className RegExp The className of the elements in the form of a regular expression.
Returns:
A function that locates and returns elements with the given className.

each(bys)

Returns a function that locates and returns elements according to one or more locators (attributes, tags, styles etc.).
Parameters:
Name Type Description
bys Array.<Object> The locators (Bys) by which the elements are identified.
Returns:
A function that locates and returns elements that matches all the locators.

id(id)

Returns a function that locates and returns elements with the provided ID parameter. The LeanFT locator is used only when the value passed is a regular expression. Otherwise, the Selenium locator is used.
Parameters:
Name Type Description
id RegExp The ID of the elements in the form of a regular expression.
Returns:
A function that locates and returns elements with the given ID.

linkText(linkText)

Returns a function that locates and returns elements with the provided linkText parameter. The LeanFT locator is used only when the value passed is a regular expression. Otherwise, the Selenium locator is used.
Parameters:
Name Type Description
linkText RegExp The linkText of the elements in the form of a regular expression.
Returns:
A function that locates and returns elements with the given linkText.

name(name)

Returns a function that locates and returns elements with the provided name parameter. The LeanFT locator is used only when the value passed is a regular expression. Otherwise, the Selenium locator is used.
Parameters:
Name Type Description
name RegExp The name of the elements in the form of a regular expression.
Returns:
A function that locates and returns elements with the given name.

role(role)

Returns a function that locates and returns elements with the provided role parameter. The LeanFT locator is used only when the value passed is a regular expression. Otherwise, the Selenium locator is used.
Parameters:
Name Type Description
role RegExp The role of the elements in the form of a regular expression.
Returns:
A function that locates and returns elements with the given role.

styles(styles)

Returns a function that locates and returns elements according to one or more styles. You can also use regular expressions.
Parameters:
Name Type Description
styles Object The styles by which the elements are identified.
Returns:
A function that locates and returns elements with matching styles.

tagName(tagName)

Returns a function that locates and returns elements with the provided tagName parameter. The LeanFT locator is used only when the value passed is a regular expression. Otherwise, the Selenium locator is used.
Parameters:
Name Type Description
tagName RegExp The tagName of the elements in the form of a regular expression.
Returns:
A function that locates and returns elements with the given tagName.

type(type)

Returns a function that locates and returns elements with the provided type parameter. The LeanFT locator is used only when the value passed is a regular expression. Otherwise, the Selenium locator is used.
Parameters:
Name Type Description
type RegExp The type of the elements in the form of a regular expression.
Returns:
A function that locates and returns elements with the given type.

visible(visible)

Returns a function that locates and returns elements that are either visible or not, depending on the paramater passed.
Parameters:
Name Type Description
visible Boolean Whether the elements are visible.
Returns:
A function that locates and returns elements that are either visible or not, depending on the paramater passed.

visibleText(text)

Returns a function that locates and returns elements with the provided visibleText parameter.
Parameters:
Name Type Description
text String The text by which the elements are identified.
Returns:
A function that locates and returns elements that contains the visibleText.