testing-library/playwright-testing-library

Playwright: how to automate scrolling thru the table

InduKrish opened this issue · 1 comments

I have a table with several rows (300+) and with the scroll bar can you please clarify how to scroll the page using playwright? the table load the records as user scrolls the page, and when the scrolling is done all the way to bottom of the table, it loads all the rows in the table. Is there a way in playwright testing library to scroll down till the end of the table ?

Before scrolling, the table shows only certain number of rows, and all other records are invisible, so when we search for something from invisible rows from the table, it is not able to find, eg: 1234 is the order no that i want to search , however it is at the bottom of table, so when i run the following code, it says it is unable to find.

Can you please advise whether i should scroll each time and search for the order no if so can you please tell me how i can scroll thru the table using playwright /playwright dom?

and how to make sure that i scroll thru all the very to bottom of the table?

note: it is infinite scroll where we the table loads certain no of rows as user scroll thru the page . and user can not scroll any further after all rows are loaded.

The table screenshot is attached below.

Screen Shot 2023-02-22 at 5 16 33 AM

Screen Shot 2023-02-22 at 5 21 42 AM

        let awardRound1 = await screen.queryByTestId('paged-table-Vacation').within().getByRole('row', {name: RegexParser("1234")}).within().queryByTestId(/td-IFVacationCrewMemberVacationAccruals-awardedRound1/).textContent();
        console.log("awardRound1" + awardRound1)
        let originalAccruedDays = await screen.queryByTestId('paged-table-Vacation').within().getByRole('row', {name: RegexParser("1234")}).within().queryByTestId(/td-IFVacationCrewMemberVacationAccruals-originalAccruedDays/).textContent();
        console.log("originalAccruedDays" + originalAccruedDays)

Hi @InduKrish, I'll refer you to my comment on the related/duplicate issue that was posted.

[...] I'm sorry, but this really has nothing to do with playwright-testing-library. I'd recommend checking out the Playwright Community resources and perhaps ask in Discord or on Stack Overflow.

You might try selecting the last row in the table and invoking Locator.scrollIntoViewIfNeeded().