cypress-cucumber-steps
Version:
Cypress Cucumber step definitions
103 lines • 3.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.When_I_find_elements_by_title = When_I_find_elements_by_title;
exports.When_I_find_element_by_title = When_I_find_element_by_title;
var cypress_cucumber_preprocessor_1 = require("@badeball/cypress-cucumber-preprocessor");
var utils_1 = require("../utils");
/**
* When I find elements by title:
*
* ```gherkin
* When I find elements by title {string}
* ```
*
* Finds elements with a matching `title` attribute. This will also find `title` elements within SVGs.
*
* @example
*
* ```gherkin
* When I find elements by title "Title"
* ```
*
* With [options](https://docs.cypress.io/api/commands/get#Arguments):
*
* ```gherkin
* When I find elements by title "Title"
* | log | true |
* | timeout | 4000 |
* | withinSubject | null |
* | includeShadowDom | false |
* | pseudoSelector | visible |
* ```
*
* @remarks
*
* This precedes steps like {@link When_I_click | "When I click"}. For example:
*
* ```gherkin
* When I find elements by title "Close"
* And I get 1st element
* And I click
* ```
*
* Inspired by Testing Library's [ByTitle](https://testing-library.com/docs/queries/bytitle).
*
* @see
*
* - {@link When_I_find_element_by_title | When I find element by title}
*/
function When_I_find_elements_by_title(title, options) {
var selectors = [
"[title=".concat(JSON.stringify(title), "]"),
"svg title:contains(".concat(JSON.stringify(title), ")"),
];
(0, utils_1.setCypressElement)(cy.get(selectors.join(','), (0, utils_1.getOptions)(options)));
}
(0, cypress_cucumber_preprocessor_1.When)('I find elements by title {string}', When_I_find_elements_by_title);
/**
* When I find element by title:
*
* ```gherkin
* When I find element by title {string}
* ```
*
* Finds the first element that has a matching `title` attribute. This will also find a `title` element within an SVG.
*
* @example
*
* ```gherkin
* When I find element by title "Title"
* ```
*
* With [options](https://docs.cypress.io/api/commands/get#Arguments):
*
* ```gherkin
* When I find element by title "Title"
* | log | true |
* | timeout | 4000 |
* | withinSubject | null |
* | includeShadowDom | false |
* | pseudoSelector | visible |
* ```
*
* @remarks
*
* This precedes steps like {@link When_I_click | "When I click"}. For example:
*
* ```gherkin
* When I find element by title "Close"
* And I click
* ```
*
* Inspired by Testing Library's [ByTitle](https://testing-library.com/docs/queries/bytitle).
*
* @see
*
* - {@link When_I_find_elements_by_title | When I find elements by title}
*/
function When_I_find_element_by_title(title, options) {
When_I_find_elements_by_title(title, options);
(0, utils_1.setCypressElement)((0, utils_1.getCypressElement)().first());
}
(0, cypress_cucumber_preprocessor_1.When)('I find element by title {string}', When_I_find_element_by_title);
//# sourceMappingURL=title.js.map