Skip to content

Commit

Permalink
Adding 2 more definitions and correcting mistakes.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterszeles committed Apr 19, 2021
1 parent 300aa77 commit a26f85c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ Given, When, Then, And
| Given / When / Then / And | I select from dropdown "string" "string" |
| Given / When / Then / And | I select "string" |
| Given / When / Then / And | Label "string" is present |
| Given / When / Then / And | Set email at label "string" to "string" |
| Given / When / Then / And | Set input at label "string" to "string" |
| Given / When / Then / And | Set input "string" to "string" |
| Given / When / Then / And | Set textarea at label "string" to "string" |


## Develop a Gherkin command 💻
Expand Down
26 changes: 26 additions & 0 deletions cypress/tests/common/set_email_at_label_STRING_to_STRING.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Given, When, Then, And} from "cypress-cucumber-preprocessor/steps";

Given(`Set email at label {string} to {string}`, (v1, v2) => {
cy.get("body").contains(v1).parent().within(() => {
cy.get("input[type='email']").type(v2)
})
});

When(`Set email at label {string} to {string}`, (v1, v2) => {
cy.get("body").contains(v1).parent().within(() => {
cy.get("input[type='email']").type(v2)
})
});

Then(`Set email at label {string} to {string}`, (v1, v2) => {
cy.get("body").contains(v1).parent().within(() => {
cy.get("input[type='email']").type(v2)
})
});

And(`Set email at label {string} to {string}`, (v1, v2) => {
cy.get("div").contains(v1).parent().within(() => {
cy.get("input[type='email']").type(v2)
})
});

26 changes: 26 additions & 0 deletions cypress/tests/common/set_textarea_at_label_STRING_to_STRING.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Given, When, Then, And} from "cypress-cucumber-preprocessor/steps";

Given(`Set textarea at label {string} to {string}`, (v1, v2) => {
cy.get("body").contains(v1).parent().within(() => {
cy.get("textarea").type(v2)
})
});

When(`Set textarea at label {string} to {string}`, (v1, v2) => {
cy.get("body").contains(v1).parent().within(() => {
cy.get("textarea").type(v2)
})
});

Then(`Set textarea at label {string} to {string}`, (v1, v2) => {
cy.get("body").contains(v1).parent().within(() => {
cy.get("textarea").type(v2)
})
});

And(`Set textarea at label {string} to {string}`, (v1, v2) => {
cy.get("div").contains(v1).parent().within(() => {
cy.get("textarea']").type(v2)
})
});

4 changes: 2 additions & 2 deletions cypress/tests/examples/bootstrap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

Scenario: Testing the bootstrap components
Given I am on "https://getbootstrap.com/docs/5.0/forms/form-control/" page
Then Set input at label "Email address" to "[email protected]"
Then Set input at label "Example textaera" to "Lorem ipsum."
Then Set email at label "Email address" to "[email protected]"
Then Set textarea at label "Example textarea" to "Lorem ipsum."
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@peterszeles/cypress-cucumber-testing",
"version": "1.1.8",
"version": "1.1.9",
"description": "DSL For Generic Functional testing",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a26f85c

Please sign in to comment.