0

For example, this is working:

cy.nodes("[id='22132']").position('x')

And this isn't:

cy.nodes("[id=targetID]").position('x')

How can I reference ID as a variable?

1 Answer 1

2

You can use something fancy like Template-Strings:

cy.nodes(`[id='${variable}']`).position('x');

Or you can use something simple like normal string concatination:

cy.nodes("[id='" + variable + "']").position('x');
1
  • Great, if this solves your question, please accept my answer :)
    – Stephan T.
    May 14, 2020 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.