'i am using p-tableCheckbox and i want to click using Cypress

i got a problem i am using p-tableCheckbox and I want to click it using Cypress

i tried cy.get('[id="pr_id_2-table"]').find('div').contains('role="checkbox"').click();

but it's not working any help is heighly appreciated



Solution 1:[1]

most probably this will work

cy.get('#pr_id_2-table [role="checkbox"]').click();

Solution 2:[2]

.contains() is for finding text, but role="checkbox" is an attribute.

You should search for it with square brackets, same way as [id="pr_id_2-table"] but using .find() to search inside the previous subject.

cy.get('[id="pr_id_2-table"]')
  .find('div')
  .find('[role="checkbox"]')
  .click()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zhenëk
Solution 2 Fody