luciole/chain
Functions
pub fn clear(prev: Chainable(a)) -> Chainable(a)
Clear the value of an input or textarea.
Unsafe to chain further commands. Yields the subject it was given.
pub fn click(prev: Chainable(a)) -> Chainable(a)
Click a DOM element.
Unsafe to chain further commands. Yields the subject it was given.
pub fn contain(
prev: Chainable(a),
selector: String,
) -> Chainable(b)
Get the DOM element containing at least the text.
Yields the new DOM element found.
pub fn each(
prev: Chainable(a),
callback: fn(a) -> b,
) -> Chainable(a)
Iterate through an array like structure and apply a function to each of its elements.
Unsafe to chain further commands. Yields the subject it was given.
pub fn find(prev: Chainable(a), selector: String) -> Chainable(b)
Get the descendent DOM elements of a specific selector.
Yields the new DOM element found.
A selector can be one of or a combination of :
- ID selector :
#elementId - Class Selectors:
.elementClass - Tag Selectors:
div,span - Attribute Selectors:
[type="text"],[href="/home"] - Data Attribute Selectors:
[data-cy="button-confirm"] - Combinator Selectors:
div > p,div + p,div ~ p - XPath Selectors:
//div[@id='elementId']
pub fn invoke(
prev: Chainable(a),
callback: String,
) -> Chainable(b)
Invoke a function on the previously yielded subject.
If you chain further commands, the function of invoke will be called multiple times. Yields the return value of the method.
Example: cy.get('.input').invoke('val').should('eq', 'foo')
pub fn map(
prev: Chainable(a),
callback: fn(a) -> b,
) -> Chainable(b)
Apply a function on the subject of the previous command. Wraps the result in Chainable.
Unsafe to return a DOM element from the callback function and chain further commands. Yields what is returned by the callback function.
pub fn select_file(
prev: Chainable(a),
filepath: String,
) -> Chainable(a)
Selects a file in an HTML5 input element.
Unsafe to chain further commands. Yields the subject it was given.
filepath: path to a file within the project root
pub fn then(
prev: Chainable(a),
callback: fn(a) -> Chainable(b),
) -> Chainable(b)
Apply a function on the subject of the previous command. The function should return a Chainable.
Unsafe to return a DOM element from the callback function and chain further commands. Yields what is returned by the callback function.
pub fn within(
prev: Chainable(a),
callback: fn() -> Chainable(b),
) -> Chainable(a)
Scopes all subsequent Cypress commands to within the element. Restrict the DOM access of the callback function to the element. Useful when working within a particular group of elements such as a <form>.
Unsafe to chain further commands. Yields the subject it was given.
pub fn write(prev: Chainable(a), text: String) -> Chainable(a)
Type into an input or textarea. (Named “write” because “type” is ambiguous and is a reserved keyword in Gleam).
Unsafe to chain further commands. Yields the subject it was given.