Skip to content

Selectors with double quotes are failing within cy.origin #32827

@ayush000

Description

@ayush000

Current behavior

Within cy.origin block, if I try to to select a DOM element with double quotes, I get an error from Cypress.

cypress_runner.js:8298 Uncaught Error: Syntax error, unrecognized expression: BUTTON[id="testBtn"][data-prop1="{"test": "str"}"][value=""]
    at find.error (cypress_runner.js:8298:8)
    at tokenize (cypress_runner.js:8964:8)
    at select (cypress_runner.js:9423:20)
    at jQuery.find (cypress_runner.js:7734:9)
    at jQuery.fn.init.find (cypress_runner.js:9633:11)
    at new jQuery.fn.init (cypress_runner.js:9743:32)
    at Object.query (cypress_runner.js:17940:10)
    at $Cy.$$ (cypress_runner.js:147542:57)
    at $Cypress.jqueryProxyFn (cypress_runner.js:41158:21)
    at props.reifyElement (cypress_runner.js:177507:36)
    at get 0 (cypress_runner.js:177392:24)
    at Object.get (cypress_runner.js:177409:22)
    at Proxy.map (<anonymous>)
    at reifyLogFromSerialization (cypress_runner.js:177634:41)
    at PrimaryOriginCommunicator.onMessage (cypress_runner.js:176966:103)
    at zh (index-cQEACcA0.js:1728:116541)

Desired behavior

Cyprss should be able to find a selector with " within cy.origin block and not throw any errors

Test code to reproduce

https://github.com/ayush000/cypress-quotes-attribute

  • Run the server using npm start
  • In a separate terminal, run the test using npm run cypress:run

Cypress Version

15.5.0

Debug Logs

1) page
       opens test HTML file with cy.origin:
     Error: The following error originated from your application code, not from Cypress.

  > Syntax error, unrecognized expression: BUTTON[id="testBtn"][data-prop1="test""][value=""]

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.

https://on.cypress.io/uncaught-exception-from-application
      at find.error (https://example.cypress.io/__cypress/runner/cypress_runner.js:8298:8)
      at tokenize (https://example.cypress.io/__cypress/runner/cypress_runner.js:8964:8)
      at select (https://example.cypress.io/__cypress/runner/cypress_runner.js:9423:20)
      at jQuery.find (https://example.cypress.io/__cypress/runner/cypress_runner.js:7734:9)
      at jQuery.fn.init.find (https://example.cypress.io/__cypress/runner/cypress_runner.js:9633:11)
      at new jQuery.fn.init (https://example.cypress.io/__cypress/runner/cypress_runner.js:9743:32)
      at Object.query (https://example.cypress.io/__cypress/runner/cypress_runner.js:17940:10)
      at $Cy.$$ (https://example.cypress.io/__cypress/runner/cypress_runner.js:147542:57)
      at $Cypress.jqueryProxyFn (https://example.cypress.io/__cypress/runner/cypress_runner.js:41158:21)
      at props.reifyElement (https://example.cypress.io/__cypress/runner/cypress_runner.js:177507:36)
      at get 0 (https://example.cypress.io/__cypress/runner/cypress_runner.js:177392:24)
      at Object.get (https://example.cypress.io/__cypress/runner/cypress_runner.js:177409:22)
      at Proxy.map (<anonymous>)
      at reifyLogFromSerialization (https://example.cypress.io/__cypress/runner/cypress_runner.js:177634:41)
      at PrimaryOriginCommunicator.onMessage (https://example.cypress.io/__cypress/runner/cypress_runner.js:176966:103)
      at zh (https://example.cypress.io/__/assets/index-cQEACcA0.js:1728:116541)

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions