From cb24dc698fac7b9348a0ddc9fcb30e9ff7e237f3 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Mon, 15 Jan 2024 17:31:25 -0500 Subject: [PATCH] refactor --- docs/recipes/selected-value.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/recipes/selected-value.md b/docs/recipes/selected-value.md index 4d0e92208b..4f02a7e3d1 100644 --- a/docs/recipes/selected-value.md +++ b/docs/recipes/selected-value.md @@ -270,11 +270,12 @@ Notice how the attribute value is quoted by Cypress, yet the value inside has a ```js // select the option ourselves by setting its attribute -cy.get( - `#my-data option[value=${Cypress.$.escapeSelector( - 'present"', - )}]`, -).invoke('attr', 'selected', 'selected') +const escaped = Cypress.$.escapeSelector('present"') +cy.get(`#my-data option[value=${escaped}]`).invoke( + 'attr', + 'selected', + 'selected', +) // check the selected value cy.get('#my-data option:selected').should( 'have.text',