|
| 1 | +import { SelectMenuPage } from '@pages/Widgets/GX3-440-SelecMenuPage'; |
| 2 | + |
| 3 | +describe('GX3-440 | ToolsQA | Widgets | SelectMenu - Select Menu', () => { |
| 4 | + beforeEach('Precondition: Visit website DemoQA', () => { |
| 5 | + cy.visit('https://demoqa.com/select-menu'); |
| 6 | + }); |
| 7 | + |
| 8 | + it('440 | TC1: Validate dropdown "Select Value" by select each one.', () => { |
| 9 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 10 | + SelectMenuPage.clickSelectValue(); |
| 11 | + SelectMenuPage.get.optionA().should('have.text', data.selectValue.group1.OptionA); |
| 12 | + SelectMenuPage.get.optionB().should('have.text', data.selectValue.group1.OptionB); |
| 13 | + SelectMenuPage.get.optionC().should('have.text', data.selectValue.group2.OptionC); |
| 14 | + SelectMenuPage.get.optionD().should('have.text', data.selectValue.group2.OptionD); |
| 15 | + SelectMenuPage.get.optionE().should('have.text', data.selectValue.outOfGroup.OptionE); |
| 16 | + SelectMenuPage.get.optionF().should('have.text', data.selectValue.outOfGroup.OptionF); |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + it('440 | TC2: Validate dropdown "Select Value" by selecting a random one.', () => { |
| 21 | + // Hacer clic en el menú desplegable "Select Value" |
| 22 | + SelectMenuPage.clickSelectValue(); |
| 23 | + // Obtener todas las opciones del menú |
| 24 | + SelectMenuPage.get.allOptionsSelectValue().then(options => { |
| 25 | + // Obtener la longitud de las opciones |
| 26 | + const max = options.length - 1; |
| 27 | + // Seleccionar una opción aleatoria |
| 28 | + const randomIndex = Cypress._.random(0, max); |
| 29 | + options.eq(randomIndex); |
| 30 | + // Verificar que la opción seleccionada contenga el texto 'option' |
| 31 | + SelectMenuPage.get.allOptionsSelectValue().should('contain.text', 'option'); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + it('440 | TC3: Validate show message "No options" when the type text not match in SelectMenu "Select Value"', () => { |
| 36 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 37 | + // Iniciar la acción de escribir texto en el campo de selección |
| 38 | + SelectMenuPage.typeSelectValue('Hola'); |
| 39 | + // Verificar que el mensaje mostrado sea el esperado desde el fixture |
| 40 | + SelectMenuPage.get.inputInvalidSelectValue().should('have.text', data.selectValue.messageSelectValue); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + it('440 | TC4: Validate dropdown "Select One" by selecting a random one.', () => { |
| 45 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 46 | + // Hacer clic en el menú desplegable "Select Value" |
| 47 | + // Realiza la acción en el selectOne según el fixture |
| 48 | + SelectMenuPage.clickSelectOne(); |
| 49 | + |
| 50 | + // Obtén una opción aleatoria del fixture |
| 51 | + const randomOption = Cypress._.sample(data.selectOne.options); |
| 52 | + |
| 53 | + // Ingresa el texto aleatorio en el input del selectOne |
| 54 | + SelectMenuPage.typeSelectOne(randomOption); |
| 55 | + |
| 56 | + // Realiza assertions según sea necesario |
| 57 | + // En este ejemplo, verifica que el valor seleccionado sea el mismo que ingresaste |
| 58 | + SelectMenuPage.get.allOptionsSelectOne().should('not.have.text', 'option'); |
| 59 | + }); |
| 60 | + }); |
| 61 | + |
| 62 | + it('440 | TC5: Validate show massage "No options" when the type text not match in SelectMenu "Select One"', () => { |
| 63 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 64 | + // Iniciar la acción de escribir texto en el campo de selección |
| 65 | + SelectMenuPage.typeSelectOne('HolaQueTal'); |
| 66 | + // Verificar que el mensaje mostrado sea el esperado desde el fixture |
| 67 | + SelectMenuPage.get.inputInvalidSelectOne().should('have.text', data.selectOne.messageSelectOne); |
| 68 | + }); |
| 69 | + }); |
| 70 | + |
| 71 | + it('440 | TC6: Validate dropdown "Old Style Select Menu" by selecting a random one.', () => { |
| 72 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 73 | + SelectMenuPage.clickOldSelectMenu(); |
| 74 | + const randomOption = Cypress._.sample(data.oldSelectMenu.options); |
| 75 | + SelectMenuPage.typeSelectMenu(randomOption); |
| 76 | + SelectMenuPage.get.containerOldSelectMenu().should('not.have.text', 'option'); |
| 77 | + }); |
| 78 | + }); |
| 79 | + |
| 80 | + it('440 | TC7: Validate dropdown "Multiselect drop down" by selecting a random one.', () => { |
| 81 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 82 | + SelectMenuPage.clickMultiselect(); |
| 83 | + const randomOption = Cypress._.sample(data.multiselect.options); |
| 84 | + SelectMenuPage.typeMultiselect(randomOption); |
| 85 | + SelectMenuPage.get.containerMultiselect().should('not.have.text', 'option'); |
| 86 | + }); |
| 87 | + }); |
| 88 | + |
| 89 | + it('440 | TC8: Validate dropdown "Multiselect drop down" by selecting all four.', () => { |
| 90 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 91 | + SelectMenuPage.clickMultiselect(); |
| 92 | + SelectMenuPage.clickAllOptionsMultiselect(); |
| 93 | + const arrayToString = data.multiselect.options.toString(); |
| 94 | + const replaceInString = arrayToString.replaceAll(/,/g, ''); |
| 95 | + SelectMenuPage.get.selectedOptionMultiselect().should('contain.text', replaceInString); |
| 96 | + }); |
| 97 | + }); |
| 98 | + |
| 99 | + it('440 | TC9: Validate show massage "No options" when the type text not match in SelectMenu "Multiselect drop down"', () => { |
| 100 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 101 | + // Iniciar la acción de escribir texto en el campo de selección |
| 102 | + SelectMenuPage.typeMultiselect('Morado'); |
| 103 | + // Verificar que el mensaje mostrado sea el esperado desde el fixture |
| 104 | + SelectMenuPage.get.inputInvalidMultiselect().should('have.text', data.multiselect.messageMultiselect); |
| 105 | + }); |
| 106 | + }); |
| 107 | + |
| 108 | + it('440 | TC10: Validate dropdown "Standard multi select" by selecting a random one.', () => { |
| 109 | + cy.fixture('/data/Widgets/GX3-440-SelecMenu.json').then(data => { |
| 110 | + SelectMenuPage.get.allOptionsStandardSelect().then(elm => { |
| 111 | + const max = elm.length - 1; |
| 112 | + const random = Cypress._.random(0, max); |
| 113 | + SelectMenuPage.get.allOptionsStandardSelect().eq(random).should('have.text', data.standardSelect.options[random]); |
| 114 | + }); |
| 115 | + }); |
| 116 | + }); |
| 117 | +}); |
0 commit comments