cypress-cucumber-steps
Version:
Cypress Cucumber step definitions
464 lines • 11.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.When_I_click = When_I_click;
exports.When_I_click_position = When_I_click_position;
exports.When_I_click_x_y_coordinates = When_I_click_x_y_coordinates;
exports.When_I_click_on_button = When_I_click_on_button;
exports.When_I_click_on_link = When_I_click_on_link;
exports.When_I_click_on_text = When_I_click_on_text;
exports.When_I_click_on_label = When_I_click_on_label;
exports.When_I_click_on_testid = When_I_click_on_testid;
exports.When_I_click_on_title = When_I_click_on_title;
var cypress_cucumber_preprocessor_1 = require("@badeball/cypress-cucumber-preprocessor");
var constants_1 = require("../constants");
var queries_1 = require("../queries");
var utils_1 = require("../utils");
/**
* When I click:
*
* ```gherkin
* When I click
* ```
*
* Clicks on the element found in the previous step.
*
* Alternative:
*
* - {@link When_I_click_on_text | When I click on text}
* - {@link When_I_click_position | When I click position}
* - {@link When_I_click_x_y_coordinates | When I click x-y coordinates}
*
* @example
*
* ```gherkin
* When I click
* ```
*
* With [options](https://docs.cypress.io/api/commands/click#Arguments):
*
* ```gherkin
* When I click
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | log | true |
* | force | false |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* ```
*
* @remarks
*
* A preceding step like {@link When_I_find_element_by_text | "When I find element by text"} is required. For example:
*
* ```gherkin
* When I find element by text "Text"
* And I click
* ```
*
* @see
*
* - {@link When_I_double_click | When I double-click}
* - {@link When_I_right_click | When I right-click}
*/
function When_I_click(options) {
(0, utils_1.getCypressElement)().click((0, utils_1.getOptions)(options));
}
(0, cypress_cucumber_preprocessor_1.When)('I click', When_I_click);
/**
* When I click position:
*
* ```gherkin
* When I click {string}
* ```
*
* Clicks on the position of the element found in the previous step.
*
* You can click on 9 specific positions of an element:
*
* ```
* -------------------------------------
* | top-left top top-right |
* | |
* | |
* | |
* | left center right |
* | |
* | |
* | |
* | bottom-left bottom bottom-right |
* -------------------------------------
* ```
*
* @example
*
* ```gherkin
* When I click "top-left"
* ```
*
* With [options](https://docs.cypress.io/api/commands/click#Arguments):
*
* ```gherkin
* When I click "top"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | log | true |
* | force | false |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* ```
*
* @remarks
*
* A preceding step like {@link When_I_find_element_by_text | "When I find element by text"} is required. For example:
*
* ```gherkin
* When I find element by text "Text"
* And I click "top-right"
* ```
*
* @see
*
* - {@link When_I_click | When I click}
* - {@link When_I_click_x_y_coordinates | When I click x-y coordinates}
*/
function When_I_click_position(position, options) {
(0, utils_1.getCypressElement)().click((0, utils_1.camelCase)(position), (0, utils_1.getOptions)(options));
}
(0, cypress_cucumber_preprocessor_1.When)('I click {string}', When_I_click_position);
/**
* When I click x-y coordinates:
*
* ```gherkin
* When I click {int}px and {int}px
* ```
*
* Clicks on the x-y coordinates of the element found in the previous step.
*
* @example
*
* ```gherkin
* When I click 80px and 75px
* ```
*
* With [options](https://docs.cypress.io/api/commands/click#Arguments):
*
* ```gherkin
* When I click 80px and 75px
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | log | true |
* | force | false |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* ```
*
* @remarks
*
* A preceding step like {@link When_I_find_element_by_text | "When I find element by text"} is required. For example:
*
* ```gherkin
* When I find element by text "Text"
* And I click 80px and 75px
* ```
*
* @see
*
* - {@link When_I_click | When I click}
* - {@link When_I_click_position | When I click position}
*/
function When_I_click_x_y_coordinates(x, y, options) {
(0, utils_1.getCypressElement)().click(x, y, (0, utils_1.getOptions)(options));
}
(0, cypress_cucumber_preprocessor_1.When)('I click {int}px and {int}px', When_I_click_x_y_coordinates);
/**
* When I click on button:
*
* ```gherkin
* When I click on button {string}
* ```
*
* Clicks on the first button with the matching text.
*
* @example
*
* ```gherkin
* When I click on button "Button"
* ```
*
* With options:
*
* ```gherkin
* When I click on button "Button"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | force | false |
* | includeShadowDom | false |
* | log | true |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | withinSubject | null |
* ```
*
* @see
*
* - {@link When_I_click_on_text | When I click on text}
*/
function When_I_click_on_button(text, options) {
(0, utils_1.getButtonElements)(text, constants_1.PseudoSelector.visible, options)
.first()
.click((0, utils_1.getOptions)(options));
}
(0, cypress_cucumber_preprocessor_1.When)('I click on button {string}', When_I_click_on_button);
/**
* When I click on link:
*
* ```gherkin
* When I click on link {string}
* ```
*
* Clicks on the first link with the matching text.
*
* @example
*
* ```gherkin
* When I click on link "Link"
* ```
*
* With options:
*
* ```gherkin
* When I click on link "Link"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | force | false |
* | includeShadowDom | false |
* | log | true |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | withinSubject | null |
* ```
*
* @see
*
* - {@link When_I_click_on_text | When I click on text}
*/
function When_I_click_on_link(text, options) {
(0, utils_1.getLinkElements)(text, constants_1.PseudoSelector.visible, options)
.first()
.click((0, utils_1.getOptions)(options));
}
(0, cypress_cucumber_preprocessor_1.When)('I click on link {string}', When_I_click_on_link);
/**
* When I click on text:
*
* ```gherkin
* When I click on text {string}
* ```
*
* Clicks on the first element with the matching text.
*
* Alternative:
*
* - {@link When_I_click | When I click}
*
* @example
*
* ```gherkin
* When I click on text "Text"
* ```
*
* With options:
*
* ```gherkin
* When I click on text "Text"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | force | false |
* | includeShadowDom | false |
* | log | true |
* | matchCase | true |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* ```
*
* @see
*
* - {@link When_I_click_on_button | When I click on button}
* - {@link When_I_click_on_label | When I click on label}
* - {@link When_I_click_on_link | When I click on link}
*/
function When_I_click_on_text(text, options) {
var opts = (0, utils_1.getOptions)(options);
cy.contains(text, opts).click(opts);
}
(0, cypress_cucumber_preprocessor_1.When)('I click on text {string}', When_I_click_on_text);
/**
* When I click on label:
*
* ```gherkin
* When I click on label {string}
* ```
*
* Clicks on the first label with the matching text.
*
* @example
*
* ```gherkin
* When I click on label "Label"
* ```
*
* With options:
*
* ```gherkin
* When I click on label "Label"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | force | false |
* | includeShadowDom | false |
* | log | true |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | withinSubject | null |
* | pseudoSelector | visible |
* ```
*
* @see
*
* - {@link When_I_click_on_text | When I click on text}
*/
function When_I_click_on_label(text, options) {
(0, queries_1.When_I_find_element_by_label_text)(text, options);
When_I_click(options);
}
(0, cypress_cucumber_preprocessor_1.When)('I click on label {string}', When_I_click_on_label);
/**
* When I click on test ID:
*
* ```gherkin
* When I click on test ID {string}
* ```
*
* Clicks on the first element with the matching `data-testid` or `data-test-id` attribute:
*
* ```html
* <div data-testid="test"></div>
* <div data-test-id="test"></div>
* ```
*
* _Use this only if the other actions don't work. `data-testid` or `data-test-id` don't resemble how your software is used and should be avoided if possible._
*
* @example
*
* ```gherkin
* When I click on test ID "testID"
* ```
*
* With options:
*
* ```gherkin
* When I click on test ID "testID"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | force | false |
* | includeShadowDom | false |
* | log | true |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | withinSubject | null |
* ```
*
* @see
*
* - {@link When_I_click_on_text | When I click on text}
*/
function When_I_click_on_testid(testId, options) {
(0, utils_1.getTestIdElements)(testId, constants_1.PseudoSelector.visible, options)
.first()
.click((0, utils_1.getOptions)(options));
}
(0, cypress_cucumber_preprocessor_1.When)('I click on test ID {string}', When_I_click_on_testid);
/**
* When I click on title:
*
* ```gherkin
* When I click on title {string}
* ```
*
* Clicks on the first element with the matching title.
*
* @example
*
* ```gherkin
* When I click on title "Title"
* ```
*
* With options:
*
* ```gherkin
* When I click on title "Title"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | force | false |
* | includeShadowDom | false |
* | log | true |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | withinSubject | null |
* | pseudoSelector | visible |
* ```
*
* @see
*
* - {@link When_I_click_on_text | When I click on text}
*/
function When_I_click_on_title(text, options) {
(0, queries_1.When_I_find_element_by_title)(text, options);
When_I_click(options);
}
(0, cypress_cucumber_preprocessor_1.When)('I click on title {string}', When_I_click_on_title);
//# sourceMappingURL=click.js.map