diff --git a/app/commands/actions.html b/app/commands/actions.html index f2cce5b09..08062999a 100644 --- a/app/commands/actions.html +++ b/app/commands/actions.html @@ -297,7 +297,7 @@

.rightclick()

- +

@@ -454,17 +454,34 @@

.uncheck()

.select()

To select an option in a select, use the .select() command.

-
// Select option(s) with matching text content
+          
// at first, no option should be selected
+cy.get('.action-select')
+  .should('have.value', '--Select a fruit--')
+
+// Select option(s) with matching text content
 cy.get('.action-select').select('apples')
+// confirm the apples were selected
+// note that each value starts with "fr-" in our HTML
+cy.get('.action-select').should('have.value', 'fr-apples')
 
 cy.get('.action-select-multiple')
-.select(['apples', 'oranges', 'bananas'])
+  .select(['apples', 'oranges', 'bananas'])
+  // when getting multiple values, invoke "val" method first
+  .invoke('val')
+  .should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])
 
 // Select option(s) with matching value
 cy.get('.action-select').select('fr-bananas')
+  // can attach an assertion right away to the element
+  .should('have.value', 'fr-bananas')
 
 cy.get('.action-select-multiple')
-  .select(['fr-apples', 'fr-oranges', 'fr-bananas'])
+ .select(['fr-apples', 'fr-oranges', 'fr-bananas']) + .invoke('val') + .should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas']) +// assert the selected values include oranges +cy.get('.action-select-multiple') + .invoke('val').should('include', 'fr-oranges')
diff --git a/cypress/integration/examples/actions.spec.js b/cypress/integration/examples/actions.spec.js index 11434d399..16c279233 100644 --- a/cypress/integration/examples/actions.spec.js +++ b/cypress/integration/examples/actions.spec.js @@ -183,17 +183,34 @@ context('Actions', () => { it('.select() - select an option in a