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;
10 getTagElementContainsText : typeof getTagElementContainsText;
11 isElementNotContainsAttr : typeof isElementNotContainsAttr;
15 /*************************************************************************
16 isElementContainsAttr : check if element with id contains some attribute
17 *************************************************************************/
18 function isElementContainsAttr(id : string, attr: string) : void {
19 cy.getElementByDataTestsId(id).should('have.attr', attr);
22 /*************************************************************************
23 isElementContainsAttr : check if element with id not contains some attribute
24 *************************************************************************/
25 function isElementNotContainsAttr(id : string, attr: string) : void {
26 cy.getElementByDataTestsId(id).should('not.have.attr', attr);
29 /*********************************************************
30 isElementDisabled : check if element with id is disabled
31 *********************************************************/
32 function isElementDisabled(id : string) : void {
33 cy.getElementByDataTestsId(id).should('be:disabled');
36 function isElementEnabled(id : string) : void {
37 cy.getElementByDataTestsId(id).should('be:enabled');
40 /****************************************************************
41 hasClass : check if element with id contains some class name
42 ****************************************************************/
43 function hasClass(id : string, className : string) : void {
44 cy.getElementByDataTestsId(id).should('have.class', className);
47 function getElementByDataTestsId(dataTestsId : string) : Chainable<JQuery<HTMLElement>> {
48 return cy.get( "[data-tests-id='" + dataTestsId +"']");
51 /**************************************************
52 getTagElementContainsText : return tag with text
53 **************************************************/
54 function getTagElementContainsText(tag : string, text : string) : Chainable<JQuery<HTMLElement>> {
55 return cy.contains(tag,text);
59 Cypress.Commands.add('isElementContainsAttr', isElementContainsAttr);
60 Cypress.Commands.add('isElementDisabled', isElementDisabled);
61 Cypress.Commands.add('isElementEnabled', isElementEnabled);
62 Cypress.Commands.add('hasClass', hasClass);
63 Cypress.Commands.add('getElementByDataTestsId', getElementByDataTestsId);
64 Cypress.Commands.add('getTagElementContainsText', getTagElementContainsText);
65 Cypress.Commands.add('isElementNotContainsAttr', isElementNotContainsAttr);