login.cy.ts 804 B

123456789101112131415161718192021222324
  1. // import { describe, it } from 'node:test';
  2. import LoginPage from '../support/pageObjects/LoginPage';
  3. // import "cypress";
  4. describe('Login Page', () => {
  5. const loginPage = new LoginPage();
  6. beforeEach(() => {
  7. loginPage.visit();
  8. loginPage.getUsernameInput().should('be.visible');
  9. loginPage.getPasswordInput().should('be.visible');
  10. loginPage.getSubmitButton().should('be.visible');
  11. });
  12. it('should successfully log in with correct credentials', () => {
  13. loginPage.login('admin', '123456');
  14. cy.contains('登录成功').should('be.visible', { timeout: 10000 });
  15. });
  16. it('should show an error message for incorrect credentials', () => {
  17. loginPage.login('wronguser', 'wrongpassword');
  18. cy.contains('登录失败').should('be.visible', { timeout: 10000 });
  19. });
  20. });