cypress-saveLogAndFilter: post logine api done.

This commit is contained in:
chiayin
2023-05-04 14:56:45 +08:00
parent 162af24a2a
commit 739718f3d5
4 changed files with 103 additions and 2 deletions

View File

@@ -10,7 +10,24 @@
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
const loginApiUrl = Cypress.env('loginApiUrl');
Cypress.Commands.add('login', () => {
cy.request({
method: 'POST',
url: loginApiUrl,
form: true,
body: {
username: Cypress.env('user').username,
password: Cypress.env('user').password
}
}).then(response => {
console.log(response);
cy.log(response)
const token = response.body.access_token;
cy.setCookie('luciaToken', token);
})
});
// 呼叫方式: cy.login()
//
//
// -- This is a child command --