-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage of environment #1101
Comments
You could find a const shouldContain = (...names) => ($lis) => {
names.forEach(name =>
expect($lis).contain(name)
)
}
cy.get(‘.myclassname li’).then(shouldContain('Sugar', 'Juice', 'Bread', 'Ball')) |
Seems as if you could use Cypress let names = ['Sugar', 'Juice', 'Bread', 'Ball']
cy.get(‘.myclassname li’).each(($li, i, $lis) => {
expect($li).to.contain(names[i])
}) |
Thank you all of you for your answers. im used to use the following code before your help ...('.myclassname li')... im used li not div but when i used your code with li it failed but with div it run successfuly the code i used before your help .... ('.myclassname li')..... cy.get('div[id="12345"]').click()
cy.get('.myclassname li').should(($lis) => {
expect($lis).contain('Sugar')
expect($lis).contain('Juice')
expect($lis).contain('Bread')
expect($lis).contain('Ball')
}) I couldnt run your code with li but it runs with div ....('.myclassname div').... cy.get('div[id="12345"]').click()
var names = ["Sugar", "Juice", "Bread", "Ball"]
cy.get('.myclassname div').each(($div, i, $lis) => {
expect($li).to.contain(names[i])
}) in the web page Im trying to test, all the li's which Im trying to check are in div tags seperatly |
Can you make a reproducible small example, maybe even in the fork of https://github.com/cypress-io/cypress-example-kitchensink with your code that shows the problem? It is hard to see what is going on and what you expect to happen via code snippets in this issue. |
Test code:
I have some li or option values and i want to check if those exists so i use the following usage for this purpose.
as you see, i have to write every value i have one by one. Is there a way to define all the values i have in a variable and use that variable instead of writing all the values one by one like above
The text was updated successfully, but these errors were encountered: