aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/cypress/support/elements/element.actions.ts
blob: 6d63e9fda8295c57b5073083acd787c13bae89cb (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import Chainable = Cypress.Chainable;

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

/*************************************************************************
 isElementContainsAttr : check if element with id contains some attribute
 *************************************************************************/
function isElementContainsAttr(id : string, attr: string) : void {
  cy.getElementByDataTestsId(id).should('have.attr', attr);
}

/*************************************************************************
 isElementContainsAttr : check if element with id not contains some attribute
 *************************************************************************/
function isElementNotContainsAttr(id : string, attr: string) : void {
  cy.getElementByDataTestsId(id).should('not.have.attr', attr);
}

/*********************************************************
 isElementDisabled : check if element with id is disabled
 *********************************************************/
function isElementDisabled(id : string) : void {
  cy.getElementByDataTestsId(id).should('be:disabled');
}

function isElementEnabled(id : string) : void {
  cy.getElementByDataTestsId(id).should('be:enabled');
}

/****************************************************************
 hasClass : check if element with id contains some class name
 ****************************************************************/
function hasClass(id : string, className : string) : void {
  cy.getElementByDataTestsId(id).should('have.class', className);
}

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

/**************************************************
 getTagElementContainsText : return tag with text
 **************************************************/
function getTagElementContainsText(tag : string, text : string) : Chainable<JQuery<HTMLElement>> {
  return cy.contains(tag,text);
}


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);
Cypress.Commands.add('getTagElementContainsText', getTagElementContainsText);
Cypress.Commands.add('isElementNotContainsAttr', isElementNotContainsAttr);