Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame^] | 1 | declare namespace Cypress { |
| 2 | interface Chainable { |
| 3 | typeToInput : typeof typeToInput; |
| 4 | blurInput : typeof blurInput; |
| 5 | focusInput : typeof focusInput; |
| 6 | shouldInputContainsText: typeof shouldInputContainsText; |
| 7 | } |
| 8 | } |
| 9 | |
| 10 | /********************************** |
| 11 | Type to input with id some text |
| 12 | *********************************/ |
| 13 | function typeToInput(id : string, text : string) : void { |
| 14 | cy.get( "[data-tests-id='" + id +"']") |
| 15 | .type(text, {force: true}); |
| 16 | } |
| 17 | |
| 18 | /******************** |
| 19 | blur input with id |
| 20 | ********************/ |
| 21 | function blurInput(id : string) : void { |
| 22 | cy.get( "[data-tests-id='" + id +"']") |
| 23 | .blur(); |
| 24 | } |
| 25 | |
| 26 | /******************** |
| 27 | focus input with id |
| 28 | ********************/ |
| 29 | function focusInput(id : string) : void { |
| 30 | cy.get( "[data-tests-id='" + id +"']") |
| 31 | .focus(); |
| 32 | } |
| 33 | |
| 34 | /***************************************** |
| 35 | test if input with id contains some text |
| 36 | ****************************************/ |
| 37 | function shouldInputContainsText(id : string, text : string) : void { |
| 38 | cy.get( "[data-tests-id='" + id +"']") |
| 39 | .contains('text') |
| 40 | } |
| 41 | |
| 42 | Cypress.Commands.add('typeToInput', typeToInput); |
| 43 | Cypress.Commands.add('blurInput', blurInput); |
| 44 | Cypress.Commands.add('focusInput', focusInput); |
| 45 | Cypress.Commands.add('shouldInputContainsText', shouldInputContainsText); |
| 46 | |