From a26f85c9ce3ce01f9c711fb1f1b18cc70a21d30b Mon Sep 17 00:00:00 2001 From: peterszeles Date: Mon, 19 Apr 2021 11:21:40 +0200 Subject: [PATCH] Adding 2 more definitions and correcting mistakes. --- README.md | 2 ++ .../set_email_at_label_STRING_to_STRING.js | 26 +++++++++++++++++++ .../set_textarea_at_label_STRING_to_STRING.js | 26 +++++++++++++++++++ cypress/tests/examples/bootstrap.feature | 4 +-- package.json | 2 +- 5 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 cypress/tests/common/set_email_at_label_STRING_to_STRING.js create mode 100644 cypress/tests/common/set_textarea_at_label_STRING_to_STRING.js diff --git a/README.md b/README.md index e858bf6..6ea66d2 100644 --- a/README.md +++ b/README.md @@ -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 💻 diff --git a/cypress/tests/common/set_email_at_label_STRING_to_STRING.js b/cypress/tests/common/set_email_at_label_STRING_to_STRING.js new file mode 100644 index 0000000..2c059f8 --- /dev/null +++ b/cypress/tests/common/set_email_at_label_STRING_to_STRING.js @@ -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) + }) +}); + diff --git a/cypress/tests/common/set_textarea_at_label_STRING_to_STRING.js b/cypress/tests/common/set_textarea_at_label_STRING_to_STRING.js new file mode 100644 index 0000000..4081c12 --- /dev/null +++ b/cypress/tests/common/set_textarea_at_label_STRING_to_STRING.js @@ -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) + }) +}); + diff --git a/cypress/tests/examples/bootstrap.feature b/cypress/tests/examples/bootstrap.feature index 6365a91..b38d5bf 100644 --- a/cypress/tests/examples/bootstrap.feature +++ b/cypress/tests/examples/bootstrap.feature @@ -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 "testUser@testemail.domain" - Then Set input at label "Example textaera" to "Lorem ipsum." + Then Set email at label "Email address" to "testUser@testemail.domain" + Then Set textarea at label "Example textarea" to "Lorem ipsum." diff --git a/package.json b/package.json index 3bbe4bb..bbf28b5 100644 --- a/package.json +++ b/package.json @@ -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": {