1 import Chainable = Cypress.Chainable;
3 declare namespace Cypress {
5 isElementContainsAttr : typeof isElementContainsAttr;
6 isElementDisabled : typeof isElementDisabled;
7 isElementEnabled : typeof isElementEnabled;
8 hasClass : typeof hasClass;
9 getElementByDataTestsId : typeof getElementByDataTestsId;
13 /*************************************************************************
14 isElementContainsAttr : check if element with id contains some attribute
15 *************************************************************************/
16 function isElementContainsAttr(id : string, attr: string) : void {
17 cy.get("[data-tests-id='" + id +"']")
18 .should('have.attr', attr);
21 /*********************************************************
22 isElementDisabled : check if element with id is disabled
23 *********************************************************/
24 function isElementDisabled(id : string) : void {
25 cy.get( "[data-tests-id='" + id +"']").should('be:disabled');
28 function isElementEnabled(id : string) : void {
29 cy.get( "button[data-tests-id='" + id +"']").should('be:enabled');
32 /****************************************************************
33 hasClass : check if element with id contains some class name
34 ****************************************************************/
35 function hasClass(id : string, className : string) : void {
36 cy.get( "[data-tests-id='" + id +"']")
37 .should('have.class', className);
40 function getElementByDataTestsId(dataTestsId : string) : Chainable<JQuery<HTMLElement>> {
41 return cy.get( "[data-tests-id='" + dataTestsId +"']");
45 Cypress.Commands.add('isElementContainsAttr', isElementContainsAttr);
46 Cypress.Commands.add('isElementDisabled', isElementDisabled);
47 Cypress.Commands.add('isElementEnabled', isElementEnabled);
48 Cypress.Commands.add('hasClass', hasClass);
49 Cypress.Commands.add('getElementByDataTestsId', getElementByDataTestsId);