Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #244

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 114 additions & 1 deletion cypress/e2e/webTables.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,120 @@
/// <reference types='cypress' />
const { faker } = require('@faker-js/faker');

const username = faker.internet.userName();
const lastname = faker.name.lastName();
const email = faker.internet.email();

describe('Web Tables page', () => {
it('', () => {
beforeEach(() => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty lines between beforeEach and all tests

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cy.visit('https://demoqa.com/webtables');
});
it('should check Pagination', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider that describe + test name should create summary together - in this case we have
Web Tables page + should check Pagination // Web Tables shouldn't check pagination.

Better to write
Web Tables page + should allow user to change page

Check and fix everywhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cy.get('.rt-tbody .rt-tr-group').should('have.length', 10);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use more descriptive selectors everywhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сhange

cy.get('.-next').should('be.visible').and('not.be.disabled');
cy.get('img[src="/images/Toolsqa.jpg"]').should('exist');
cy.url().should('eq', 'https://demoqa.com/webtables');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this assert is doing here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change

});
it('should check Rows count selection', () => {
cy.get('select[aria-label="rows per page"]').should('exist');
cy.get('select[aria-label="rows per page"]').should('exist').select('20');
});
it('should Add a new worker', () => {
cy.get('#addNewRecordButton').click();
cy.get('#firstName').type(username);
cy.get('#lastName').type(lastname);
cy.get('#userEmail').type(email);
cy.get('#age').type('99');
cy.get('#salary').type('1000');
cy.get('#department').type('IT');
cy.get('#submit').click();
cy.get('.rt-tbody').contains(username).should('exist');
});
it('should Delete a worker', () => {
cy.get('#addNewRecordButton').click();
cy.get('#firstName').type(username);
cy.get('#lastName').type(lastname);
cy.get('#userEmail').type(email);
cy.get('#age').type('99');
cy.get('#salary').type('1000');
cy.get('#department').type('IT');
cy.get('#submit').click();
cy.get('.rt-tbody').contains(username).should('exist');

cy.get('.rt-tbody').contains(username)
.parents('div.rt-tr')
.find('span[title="Delete"]')
.click();

cy.get('.rt-tbody').contains(username).should('not.exist');
});
it('should Delete all workers', () => {
cy.get('.rt-tbody .rt-tr')
.eq(0)
.find('[id^="delete-record-"]')
.click();
cy.get('.rt-tbody .rt-tr')
.eq(1)
.find('[id^="delete-record-"]')
.click();
cy.get('.rt-tbody .rt-tr')
.eq(0)
.find('[id^="delete-record-"]')
.click();
cy.get(`.rt-noData`).should('contain', 'No rows found');
});
it('should Find a worker in the search field and edit it.', () => {
cy.get('input#searchBox').type('Cierra');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add search keyword to const

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add

cy.get('input#searchBox').clear();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we have asserts to check search results?


cy.get('.rt-tr').should('exist');
cy.get('#addNewRecordButton').click();
cy.get('#firstName').clear();
cy.get('#firstName').type(username);
cy.get('#lastName').clear();
cy.get('#lastName').type(lastname);
cy.get('#userEmail').type(email);
cy.get('#age').type('40');
cy.get('#salary').type('10000');
cy.get('#department').type('IT');
cy.get('#submit').click();
});
it('should Validate data in the worker row after editing the worker', () => {
cy.get('#searchBox').type('[email protected]');

cy.get('.rt-tr').should('exist');
cy.get('.action-buttons [title="Edit"]').click();
cy.get('#firstName').clear();
cy.get('#firstName').type(username);
cy.get('#lastName').clear();
cy.get('#lastName').type(lastname);
cy.get('#submit').click();

cy.get('.rt-tr').should('contain', username);
cy.get('.rt-tr').should('contain', lastname);
});
it('should Check the search by all column values', () => {
cy.get('#searchBox').type('Cierra');
cy.get('.rt-tbody').should('contain', 'Cierra');
cy.get('#searchBox').clear();

cy.get('#searchBox').type('Vega');
cy.get('.rt-tbody').should('contain', 'Vega');
cy.get('#searchBox').clear();

cy.get('#searchBox').type(39);
cy.get('.rt-tbody').should('contain', 39);
cy.get('#searchBox').clear();

cy.get('#searchBox').type('[email protected]');
cy.get('.rt-tbody').should('contain', '[email protected]');
cy.get('#searchBox').clear();

cy.get('#searchBox').type(10000);
cy.get('.rt-tbody').should('contain', 10000);
cy.get('#searchBox').clear();

cy.get('#searchBox').type('Insurance');
cy.get('.rt-tbody').should('contain', 'Insurance');
});
});
Loading