Skip to content

Instantly share code, notes, and snippets.

@tsh-code
Created December 20, 2021 08:41
import { BasePage } from '../basePage';
export class NotesPage extends BasePage {
elements = {
noteTitleInput: 'input[type="text"]',
noteDescriptionInput: 'input[type="textarea"]',
loginButton: 'button[name="login"]',
};
constructor() {
super();
}
createNote(noteDetails: { title: string; description: string }) {
cy.get('button').contains('Add note').click();
cy.get(this.elements.noteTitleInput).type(noteDetails.title);
cy.get(this.elements.noteDescriptionInput).type(noteDetails.description);
cy.get('button').contains('Save').click();
}
createNoteAPI(noteDetails: { title: string; description: string; username: string; password: string }) {
cy.request({
method: 'POST',
url: 'https://notepage.com/oauth/v2/token',
body: {
grant_type: 'password',
username: noteDetails.username,
password: noteDetails.password,
},
}).then(() => {
cy.request({
method: 'POST',
url: 'https://notepage.com/createnote',
body: {
note_title: noteDetails.title,
note_description: noteDetails.description,
},
});
});
cy.reload();
}
deleteNote() {
cy.get('button').contains('Delete note').click();
cy.get('button').contains('Confirm').click();
}
}
export const notesPage = new NotesPage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment