0

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

ksk
  • 165
  • 14

2 Answers2

1

most probably this will work

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

Evgenii Bazhanov
  • 898
  • 1
  • 7
  • 19
1

.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()
Fody
  • 23,754
  • 3
  • 20
  • 37