brief-kite-35331
05/10/2023, 12:41 PMTypescript
Cypress.Commands.add('getRandomFromList', { prevSubject: true }, (subject) => {
return cy
.wrap(subject)
.should('have.length.above', 0)
.then(function ($items) {
return Cypress._.sampleSize($items.toArray(), 1);
});
});
goToRandomCategory() {
cy.get('#homepageCategories ul').getRandomFromList().click();
}
goToRandomEndLevelCategory() {
this.goToRandomCategory();
this.goToRandomSubCategory();
}
goToRandomSubCategory() {
cy.location('pathname').should('include', '--c'); // to ensure that the category page is loaded
cy.get('[itemtype*="SiteNavigationElement"]:nth-child(2) > ul').then((subcategories) => {
if (subcategories.length > 0) {
cy.wrap(subcategories).getRandomFromList().click();
this.goToRandomCategory();
}
});
}
It only clicks the homepage category and opens first level category but doesn't go further then that.
The weird thing is that it shows category list, I can see it but the trace says the elements are not visible :/
Can you please help 😄 ?
https://cdn.discordapp.com/attachments/1105836979695915038/1105836979846914068/image.pngâ–¾
gray-kilobyte-89541
05/10/2023, 1:41 PMbrief-kite-35331
05/11/2023, 4:10 PMbrief-kite-35331
05/15/2023, 11:48 AMTypescript
goToRandomSubCategory() {
cy.location('pathname').should('include', '--c');
recurse(
() => {
return cy.get('#container-categorySidebar > div > ul li').should(Cypress._.noop)
},
($subcategories) => $subcategories.length > 0,
{
post() {
cy.location('pathname').should('include', '--c');
},
log: true,
delay: 100,
debugLog: true
}
).getRandomFromList().click();
}brief-kite-35331
05/15/2023, 11:48 AMbrief-kite-35331
05/15/2023, 11:49 AMbrief-kite-35331
05/15/2023, 11:50 AMbrief-kite-35331
05/15/2023, 11:51 AMbrief-kite-35331
05/15/2023, 11:51 AMgray-kilobyte-89541
05/15/2023, 12:07 PMbrief-kite-35331
05/15/2023, 1:41 PMgray-kilobyte-89541
05/15/2023, 3:54 PMbrief-kite-35331
05/17/2023, 9:53 PMgray-kilobyte-89541
05/17/2023, 10:53 PMgray-kilobyte-89541
05/18/2023, 1:17 PMbrief-kite-35331
05/18/2023, 2:13 PM