Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Unable to traverse through td elements with in the same <tr> #526

@InduKrish

Description

@InduKrish

This is related to #517
First of all, thank you for your explanation in the tickets and it helps us to understand better.
and I totally understand that the playwright testing library is not supposed to be using anything like css selector and the intention of library is closely to mimic how user interacts.

All I am trying now is to achieve the below scenario using playwright testing library
would like to filter by table name test id like below, then search text - LINEHOLDER, and once text is found, click the corresponding checkbox in the same row, Can you please advise how to achieve that? will be much helpful.

I have gone thru the documentation, am unable to find anything closer. I would really to like to use testing library in my framework, Can you please help me with the example code to achieve this scenario that helps me to better understand and follow the documentation better?

Screen Shot 2022-09-22 at 8 56 40 AM

test('should access checkbox in the same row', async ({screen}) => {


const table = await screen.findByTestId('editable-nested-table-GroupCode')

const lineholderText = within(table).getByText(/LINEHOLDER*/). ---> this is going to return only LINEHOLDER - td, but how to traverse through the - td element (checkbox) in the same row - tr where LINEHOLDER text is found?

after lineholder test if found, how to access the checkbox please?
const checkbox = ???.getByRole(checkbox)
checkbox.click();
})

Can you please provide me the example to achieve this? would be really helpful and would love to use testing library across all our projects, as it the first time trying to use this for this specific scenario, your example will be much more helpful.

Again to be clear, I am not asking anything like CSS selector, I am only interested to achieve this scenario using testing library. i have to search text and perform click the same row, in other 6 tables. Your example will be so much beneficial. Thank you for all the help and guidance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions