Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | declare namespace Cypress { |
| 2 | interface Chainable { |
| 3 | selectDropdownOptionByText : typeof selectDropdownOptionByText; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 4 | checkIsOptionSelected : typeof checkIsOptionSelected; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 5 | } |
| 6 | } |
| 7 | |
| 8 | /************************************************ |
| 9 | select option with some text with select tag id |
| 10 | ************************************************/ |
| 11 | function selectDropdownOptionByText(selectId : string, optionText : string) : void { |
| 12 | cy.getElementByDataTestsId(selectId) |
| 13 | .select(optionText); |
| 14 | } |
| 15 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 16 | /************************************************ |
| 17 | check if option is selected |
| 18 | ************************************************/ |
| 19 | function checkIsOptionSelected(selectId : string, optionText : string) : void { |
| 20 | cy.getElementByDataTestsId(selectId) |
| 21 | .should('have.value', optionText) |
| 22 | } |
| 23 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 24 | Cypress.Commands.add('selectDropdownOptionByText', selectDropdownOptionByText); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 25 | Cypress.Commands.add('checkIsOptionSelected', checkIsOptionSelected); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 26 | |