Tengo una tabla web y tengo que hacer clic en el primer enlace que está habilitado en la columna 'Acción'. Entonces, en este ejemplo, las dos primeras filas no tienen el enlace habilitado, por lo que tengo que hacer clic en '8.5 AccountH'
Cuando inspecciono este elemento, el siguiente es el HTML para él
He probado muchas soluciones y algunas de ellas son las siguientes: -
cy.get('.data-table-ctn.mb-3 .data-table div.td').find('span.link').eq(1).click() OR cy.get('.data-table-ctn.mb-3 .data-table div.td i.far.check.fa-square').next().click() OR cy.get('.data-table-ctn.mb-3 .data-table div.td').find('span.link').eq(1).click({force:true}) OR cy.get('.data-table-ctn.mb-3 .data-table div.td').find('span.link').first().click()Pero ninguno está funcionando. Sería genial si la comunidad me ayuda a resolver esto.
Puedes usar force: true , debería funcionar.
cy.get('.data-table-ctn.mb-3 .data-table div.td') .find('span.link') .eq(0) .click({force: true})O
cy.get('.data-table-ctn.mb-3 .data-table div.td') .find('span.link') .first() .click({force: true})O, puede usar directamente el contenido y hacer clic en él, algo así como:
cy.contains( 'span.link', 'AccountHolder Consumer Lending Postgre Move- Prior 3 months data' ).click()Dado que los eventos burbujean, puede intentar hacer clic en la celda y el enlace debería responder.
cy.get('.data-table-ctn.mb-3 .data-table div.td').click()Usar texto en la celda para seleccionar es un selector más fuerte.
cy.contains('.data-table-ctn.mb-3 .data-table div.td', 'Prior 3 months data') .click() Usando :enabled , hay algunas opciones posibles para probar
Nota: es posible que deba examinar el elemento "fila" para elegir un selector adecuado; la clave es agregar :enabled al selector de fila.
Hacer clic en la fila
cy.get('.data-table-ctn.mb-3 .data-table') .find('.tr:enabled').first() // first enabled row (not sure what selector to use) .click() // click the rowAl hacer clic en la celda
cy.get('.data-table-ctn.mb-3 .data-table') .find('.tr:enabled').first() // first enabled row .find('.td.check-td') // checkbox cell .next() // next cell .click()Al hacer clic en lapso con alternar grupo
cy.get('.data-table-ctn.mb-3 .data-table') .find('.tr:enabled').first() // first enabled row .find('.td.check-td') // checkbox cell .next() // next cell .find('span.toggle-group') .click({force:true}) // force because hiddenEspacio de clic con descripción
cy.get('.data-table-ctn.mb-3 .data-table') .find('tr:enabled').first() // first enabled row .find('td.check-td') // checkbox cell .next() // next cell .find('span.toggle-group') .next() .click()Ref MDN Eventos
Diagrama de ejemplo: