blob: 4df62168fd8658ad45b57db3da68b63e128a3ca6 (
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
|
declare namespace Cypress {
interface Chainable {
selectDropdownOptionByText : typeof selectDropdownOptionByText;
checkIsOptionSelected : typeof checkIsOptionSelected;
validateSelectOptions: typeof validateSelectOptions;
}
}
/************************************************
select option with some text with select tag id
************************************************/
function selectDropdownOptionByText(selectId : string, optionText : string) : void {
cy.getElementByDataTestsId(selectId)
.select(optionText);
}
/************************************************
check if option is selected
************************************************/
function checkIsOptionSelected(selectId : string, optionText : string) : void {
cy.getElementByDataTestsId(selectId)
.should('have.value', optionText)
}
/************************************************
validate the options of selected drop down
************************************************/
function validateSelectOptions(rolesCriteria: string, values: string[]){
values.forEach((value)=>{
selectDropdownOptionByText(rolesCriteria, value);
checkIsOptionSelected(rolesCriteria, value);
});
}
Cypress.Commands.add('selectDropdownOptionByText', selectDropdownOptionByText);
Cypress.Commands.add('checkIsOptionSelected', checkIsOptionSelected);
Cypress.Commands.add('validateSelectOptions', validateSelectOptions);
|