Professional Documents
Culture Documents
npm install cypress - save-dev 5. Trỏ đến thư mục .bin (hoặc gõ npx) : cypress open
npm install cypress - save-dev 5. Trỏ đến thư mục .bin (hoặc gõ npx) : cypress open
=====================================================================
Setup cypress:
=====================================================================
Cy.contains(‘nội dung’).click(): tìm phần tử có nội dung rồi click vào nó.
Note: case phần tử click bị che thì thêm {force:true} bên trong dấu ngoặc của click
.scrollIntoView(): để scroll
.should(‘have.legnth’,1): kiểm tra xem phần tử có xuất hiện không. 1 là xuất hiện 1 lần, 0 là
không xuất hiện.
.invoke(‘text’).should(‘eq’,’nội dung’): kiểm tra xem có hiển thị dòng text đó không.
================
VSCode
describe('Login', () => {
beforeEach(function () {
cy.visit('https://hienoti.tabulalearning.net/')
});
it('passes', () => {
//cy.xpath(input[placeholder="Your email
address"]).type('text').should('have.value','hie.noti@yopmail.com')
// Cy.wait(3000)
})
it('fail', () => {
it.only('empty',()=>{
})
})
})
button.forEach(elament => {
cy.xpath(elament).click()
});
})
========
Cypress.Commands.add(‘type’, (locators = [], value =[]) => {
for
———-
.json