I know that this is somewhat, very basic question, but.. I have to create a cypress element, for which I have to concatenate a value between variables.
Like I have this value
const value = "100 - 299"
and I have to print a value within a string, ie
cy.get('[data-value="100 - 299"]')
I am trying everything but unable to do so. Can someone help me on this?
我会考虑模板文字- 也称为反引号
cy.get(`[data-value="${value}"]`)
You could consider concatenation.
const value = "100 - 299"
cy.get('[data-value="' + value + '"]')
Or template literals
cy.get(`[data-value="${value}"]`)
Or pre-concatenation:
const value = "100 - 299"
const fullstring = '[data-value="' + value + '"]'
cy.get(fullstring)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.