@@ -297,7 +297,7 @@ <h4><a href="https://on.cypress.io/rightclick">.rightclick()</a></h4>
297297 </ form >
298298 </ div >
299299 </ div >
300-
300+
301301 < div class ="col-xs-12 ">
302302 < hr >
303303 </ div >
@@ -454,17 +454,34 @@ <h4><a href="https://on.cypress.io/uncheck">.uncheck()</a></h4>
454454 < div class ="col-xs-7 ">
455455 < h4 > < a href ="https://on.cypress.io/select "> .select()</ a > </ h4 >
456456 < p > To select an option in a < code > select</ code > , use the < a href ="https://on.cypress.io/select "> < code > .select()</ code > </ a > command.</ p >
457- < pre > < code class ="javascript "> // Select option(s) with matching text content
457+ < pre > < code class ="javascript "> // at first, no option should be selected
458+ cy.get('.action-select')
459+ .should('have.value', '--Select a fruit--')
460+
461+ // Select option(s) with matching text content
458462cy.get('.action-select').select('apples')
463+ // confirm the apples were selected
464+ // note that each value starts with "fr-" in our HTML
465+ cy.get('.action-select').should('have.value', 'fr-apples')
459466
460467cy.get('.action-select-multiple')
461- .select(['apples', 'oranges', 'bananas'])
468+ .select(['apples', 'oranges', 'bananas'])
469+ // when getting multiple values, invoke "val" method first
470+ .invoke('val')
471+ .should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])
462472
463473// Select option(s) with matching value
464474cy.get('.action-select').select('fr-bananas')
475+ // can attach an assertion right away to the element
476+ .should('have.value', 'fr-bananas')
465477
466478cy.get('.action-select-multiple')
467- .select(['fr-apples', 'fr-oranges', 'fr-bananas'])</ code > </ pre >
479+ .select(['fr-apples', 'fr-oranges', 'fr-bananas'])
480+ .invoke('val')
481+ .should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])
482+ // assert the selected values include oranges
483+ cy.get('.action-select-multiple')
484+ .invoke('val').should('include', 'fr-oranges')</ code > </ pre >
468485 </ div >
469486 < div class ="col-xs-5 ">
470487 < div class ="well ">
0 commit comments