2018-03-06 18:56:13 +00:00
|
|
|
// ***********************************************
|
|
|
|
// 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 --
|
2018-03-07 14:58:57 +00:00
|
|
|
// Cypress.Commands.add("login", (email, password) => { ... })
|
2018-03-06 18:56:13 +00:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- 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 is will overwrite an existing command --
|
|
|
|
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
2018-03-07 14:58:57 +00:00
|
|
|
Cypress.Commands.add('loginByForm', (username, password) => {
|
|
|
|
|
|
|
|
Cypress.log({
|
|
|
|
name: 'loginByForm',
|
|
|
|
message: username + ' | ' + password
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.request({
|
|
|
|
method: 'POST',
|
|
|
|
url: '/wp-login.php', // baseUrl will be prepended to this url
|
|
|
|
form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers
|
|
|
|
body: {
|
|
|
|
log: username,
|
|
|
|
pwd: password
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|