I’m working on automating some testing with Cypress inside of SAP Hybris. Basically, I’m at the part where a list of promotions is given in the form of a table. The task that Cypress has to manage is to find a row containing 4 values (given in 4 columns) by which it can conclude that it is a unique promotion, after which it should click on it.
So, for example, there are multiple variations of the same promotion (updated numerous times) with the same name, code, and environment values, but only one has the “Published” status, which makes it unique.
The current code I’m using is this one:
// Find and click on the promotion row that matches all criteria
cy.get('tr.yw-coll-browser-hyperlink').each(($row) => {
cy.wrap($row).within(() => {
const promotionCode = 'CR_PMI_MGM_Godfather_Discount_01_More';
const promotionName = 'MGM GODFATHER Reward';
const websiteEnv = 'Costa Rica_Promotion_Group';
const promotionStatus = 'Published';
// Use contains to find specific elements
cy.get('.yw-listview-cell-label.z-label').contains(promotionCode).should('exist')
.then(() => {
cy.get('.yw-listview-cell-label.z-label').contains(promotionName).should('exist')
.then(() => {
cy.get('.yw-listview-cell-label.z-label').contains(websiteEnv).should('exist')
.then(() => {
// Scroll horizontally to the status cell
cy.get('div.z-listbox-body').should('exist').scrollTo('right', { ensureScrollable: true }).wait(500);
cy.get('.yw-listview-cell-label.z-label')
.contains(promotionStatus).should('be.visible')
.then(($status) => {
cy.log('Found status: ', $status.text());
cy.wrap($row).click({ force: true });
});
The part at which I got stucked is this: Cypress found the promotion code, name and environment (website) values, but it couldn’t find the last value, since as you can see on the screenshot below, it is not in the viewport. So what I’ve thought as a possible solution is to solve this is by scrolling the table to the right before getting the “Published” value. Although Cypress couldn’t manage to scroll the table to the right.
I believe that I’m interacting with the proper element, and I’ve included the .should('exist')
command but it didn’t help in this case. Also I don’t believe that this issue is related to timing.
1