aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/cypress/support/elements/element.actions.ts
blob: 2d30aa1b1fb44a5390961e0caab062951cc79b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Chainable = Cypress.Chainable;

declare namespace Cypress {
  interface Chainable {
    isElementContainsAttr : typeof isElementContainsAttr;
    isElementDisabled : typeof isElementDisabled;
    isElementEnabled : typeof isElementEnabled;
    hasClass : typeof hasClass;
    getElementByDataTestsId : typeof getElementByDataTestsId;
  }
}

/*************************************************************************
 isElementContainsAttr : check if element with id contains some attribute
 *************************************************************************/
function isElementContainsAttr(id : string, attr: string) : void {
  cy.get("[data-tests-id='" + id +"']")
    .should('have.attr', attr);
}

/*********************************************************
 isElementDisabled : check if element with id is disabled
 *********************************************************/
function isElementDisabled(id : string) : void {
  cy.get( "[data-tests-id='" + id +"']").should('be:disabled');
}

function isElementEnabled(id : string) : void {
  cy.get( "button[data-tests-id='" + id +"']").should('be:enabled');
}

/****************************************************************
 hasClass : check if element with id contains some class name
 ****************************************************************/
function hasClass(id : string, className : string) : void {
  cy.get( "[data-tests-id='" + id +"']")
    .should('have.class', className);
}

function getElementByDataTestsId(dataTestsId : string) : Chainable<JQuery<HTMLElement>> {
  return cy.get( "[data-tests-id='" + dataTestsId +"']");
}


Cypress.Commands.add('isElementContainsAttr', isElementContainsAttr);
Cypress.Commands.add('isElementDisabled', isElementDisabled);
Cypress.Commands.add('isElementEnabled', isElementEnabled);
Cypress.Commands.add('hasClass', hasClass);
Cypress.Commands.add('getElementByDataTestsId', getElementByDataTestsId);