Scrolling in the table component with Cypress

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>// 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 });
});
</code>
<code>// 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 }); }); </code>
// 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

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật