123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- describe('Login Page', () => {
- it('should successfully log in with correct credentials', () => {
- // Visit the base URL
- cy.visit('/');
- // Wait for the page to load and ensure the elements are present
- cy.get('[data-testid="login-username-input"]').should('be.visible');
- cy.get('[data-testid="login-password-input"]').should('be.visible');
- cy.get('[data-testid="login-submit-button"]').should('be.visible');
- // Enter the username
- cy.get('[data-testid="login-username-input"]').type('admin');
- // Enter the password
- cy.get('[data-testid="login-password-input"]').type('123456');
- // Click the login button
- cy.get('[data-testid="login-submit-button"]').click();
- // Wait for the login process to complete
- cy.contains('登录成功').should('be.visible', { timeout: 10000 });
- });
- it('should show an error message for incorrect credentials', () => {
- // Visit the base URL
- cy.visit('/');
- // Wait for the page to load and ensure the elements are present
- cy.get('[data-testid="login-username-input"]').should('be.visible');
- cy.get('[data-testid="login-password-input"]').should('be.visible');
- cy.get('[data-testid="login-submit-button"]').should('be.visible');
- // Enter the incorrect username
- cy.get('[data-testid="login-username-input"]').type('wronguser');
- // Enter the incorrect password
- cy.get('[data-testid="login-password-input"]').type('wrongpassword');
- // Click the login button
- cy.get('[data-testid="login-submit-button"]').click();
- // Wait for the error message to be visible
- cy.contains('登录失败').should('be.visible', { timeout: 10000 });
- });
- });
|