modern-dawn-86006
01/16/2023, 7:48 PMbest-flower-17510
01/17/2023, 4:34 PMpurple-afternoon-2408
01/18/2023, 4:03 AMquiet-knife-49377
01/18/2023, 1:34 PMbetter-needle-12400
01/18/2023, 9:01 PMchilly-pilot-81570
01/19/2023, 1:58 PMechoing-tent-95037
01/19/2023, 5:08 PMbest-flower-17510
01/19/2023, 5:42 PMquiet-hospital-3813
01/20/2023, 6:34 PMmodern-dawn-86006
01/22/2023, 6:16 PMgorgeous-forest-81700
01/23/2023, 1:40 PMincalculable-rainbow-43330
01/23/2023, 2:15 PMnarrow-king-20124
01/23/2023, 6:41 PMsilly-hairdresser-33662
01/23/2023, 7:53 PMmysterious-wall-17437
01/24/2023, 12:49 AMbrainy-queen-50380
01/24/2023, 5:26 AMdazzling-addition-19232
01/24/2023, 3:07 PMadorable-smartphone-87280
01/25/2023, 2:49 PMrapid-smartphone-72849
01/26/2023, 9:15 AMworried-florist-70313
01/27/2023, 4:10 PMjavascript
productList.each($el =>
cy
.wrap($el)
.should(
'satisfy',
() =>
cy.wrap($el).find('#product-title').should('contain.text', 'house blend') ||
cy.wrap($el).find('#product-description').should('contain.text', 'house blend')
)
)
This seems to produce an infinite loop though. In the end, I just want this assertion to be true if either one of the strings contains the correct substring house blend
cold-author-79999
01/30/2023, 8:56 AMbest-flower-17510
01/30/2023, 9:12 PMmodern-dawn-86006
01/30/2023, 9:26 PMmodern-dawn-86006
01/30/2023, 9:30 PMpolite-lifeguard-36257
01/30/2023, 9:33 PMlively-library-21721
01/31/2023, 8:02 AMnutritious-restaurant-91514
01/31/2023, 8:24 AMresponse.body
first, then see what appears when you console.log out response.body.messages
etc. until you get to the proper key.
I cannot tell from the test code whether you are using intercept, but if you do there is a good chance you are confusing yourself with the naming. when you use intercept command and then use e.g. cy.wait()
what you will get is an object that will contain both request and response. this means, that if you name your callback parameter response
than you would end up with something like this:
js
cy.wait('@myThing')
.then( response => {
console.log(response) // will contain response and request
console.log(response.request) // will contain request
console.log(response.response) // will contain your response
})
Iβd suggest using different alias in the .then()
callback parameter, so something like .then( myThing => {})
or even better, use destructuring:
js
cy.wait('@myThing')
.then( ({response, request}) => {
console.log(request) // will contain request
console.log(response) // will contain your response
})
this way you donβt need to worry about naming things so much. I wrote an article on using destructuring and also on finding the right key in the response object, so that might give you some more useful info:
https://filiphric.com/reading-and-testing-json-object-in-cypress
https://filiphric.com/using-destructuring-in-cypresspolite-alarm-78904
01/31/2023, 10:26 AMCannot read properties of undefined (reading 'statusCode')
most-baker-72677
01/31/2023, 11:36 AM