cypress-wp-test-utils
Version:
Cypress test utilities for WordPress
10 lines (9 loc) • 424 B
JavaScript
/**
* Sets the value of a TextControl element by its label.
*
* @param {string} label Label of the TextControl element.
* @param {string} value Value to set.
*/
export const setTextControlValueByLabel = (label, value) => {
cy.xpath(`//label[contains(@class,"components-base-control__label")][contains(text(),"${label}")]/following-sibling::input[contains(@class,"components-text-control__input")]`).type(value);
};