Complete the code to select the option with value 'option2' from the dropdown.
cy.get('select#dropdown').[1]('option2')
The select command is used to choose an option from a dropdown menu by its value or visible text.
Complete the code to select the option with visible text 'Banana' from the dropdown.
cy.get('select.fruits').[1]('Banana')
The select command can select options by their visible text, not just by value.
Fix the error in the code to select the option with value '3' from the dropdown.
cy.get('select#numbers').[1]('3')
The select command requires the option value as a string, so passing a number without quotes causes an error.
Fill both blanks to select the option with value 'green' and then verify the selection.
cy.get('select#colors').[1]('green').should('[2]', 'value', 'green')
First, use select to choose the option. Then, use should('have.attr', 'value', 'green') to verify the dropdown's value attribute.
Fill all three blanks to select the option with text 'Apple', verify the value is '1', and check the dropdown is visible.
cy.get('select#fruits').[1]('Apple').should('[2]', '[3]').should('be.visible')
Use select to pick 'Apple'. Then verify the value with should('have.value', '1'). Finally, check visibility with should('be.visible').