login.spec.ts 840 B

1234567891011121314151617181920212223
  1. describe('Login Page', () => {
  2. it('should successfully log in with correct credentials', () => {
  3. // Visit the base URL
  4. cy.visit('/');
  5. // Wait for the page to load and ensure the elements are present
  6. cy.get('[data-testid="login-username-input"]').should('be.visible');
  7. cy.get('[data-testid="login-password-input"]').should('be.visible');
  8. cy.get('[data-testid="login-submit-button"]').should('be.visible');
  9. // Enter the username
  10. cy.get('[data-testid="login-username-input"]').type('admin');
  11. // Enter the password
  12. cy.get('[data-testid="login-password-input"]').type('123456');
  13. // Click the login button
  14. cy.get('[data-testid="login-submit-button"]').click();
  15. // Wait for the login process to complete
  16. cy.contains('登录成功').should('be.visible', { timeout: 10000 });
  17. });
  18. });