Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
visual test login form
/// <reference types="Cypress" />
context('Startup', () => {
beforeEach(() => {
cy.visit('/login');
});
it('should fill login form and redirect to homepage', () => {
// Start the test
cy.eyesOpen({
testName: 'Login Form'
});
// Take a snapshot
cy.eyesCheckWindow('Login page');
// Fill the username
cy.get('[data-cy="username"]')
.type('bhaidar')
.should('have.value', 'bhaidar');
// Fill the password
cy.get('[data-cy="password"]')
.type('123$567')
.should('have.value', '123$567');
// Take a snapshot
cy.eyesCheckWindow('Login page with credentials');
// Locate and submit the form
cy.get('login-form').submit();
// Verify the app redirected you to the homepage
cy.location('pathname', { timeout: 10000 }).should('eq', '/');
// Verify the page title is "Home"
cy.title().should('eq', 'Home');
// Take a snapshot
cy.eyesCheckWindow('Home page');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.