-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move sendMessage method into a command
- Loading branch information
1 parent
7f4d585
commit f4a24fe
Showing
2 changed files
with
28 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add("login", (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) | ||
Cypress.Commands.add("sendMessage", (name, subject,email) => { | ||
//Fill in the contact form input fields with generated fake Data by faker.js and the parameters | ||
cy.get('input#name') | ||
.should('be.visible') | ||
.type(name) | ||
cy.get('input#email') | ||
.type(email) | ||
cy.get('input#phone') | ||
.type(cy.faker.phone.phoneNumber()) | ||
cy.get('input#subject') | ||
.type(subject) | ||
cy.get('textarea#description') | ||
.type(cy.faker.lorem.lines()) | ||
|
||
//Click on the 'submit' button | ||
cy.get('button#submitContact') | ||
.click() | ||
|
||
//Check if response message contains name and subject from the contact form | ||
cy.contains('h2', name) | ||
cy.contains('p', subject) | ||
}) | ||
|