Cuando hago clic en el botón con el texto 'Crear', el texto se reemplaza por '¿Confirmar?' Este es el HTML:
y el objeto de página:
create() { return cy.get('im-page.hydrated', { includeShadowDom: true }) .find('im-button', { includeShadowDom: true }) .eq(1) .find('button', { includeShadowDom: true }) .click({ force: true }) } confirmBtn() { return cy.get('im-page.hydrated').find('im-button') .eq(1) .find('button.success.outline') .contains('Confirm?') }Luego, cuando Cypress hace clic en Confirmar, aparece este error:
Hay un problema registrado doc.createTreeWalker no es una función #20813 pero aún no se ha resuelto.
Desde el código fuente, la parte del doc se refiere al tema anterior, es decir, el elemento antes de .find() que arriba es cy.get('im-page.hydrated').find('im-button').eq(1) .
Supongo que debido a que el botón cambia al hacer clic en Crear, algo en ese tema anterior deja de ser válido cuando intenta acceder al botón Confirmar.
Un par de ideas para probar (solo suposiciones en esta etapa)
// using jquery to avoid the treeWalker (used by the .find() command) cy.get('im-page.hydrated im-button:eq(1) button.success.outline:contains(Confirm)') // using an alias and "withinSubject" option to explicitly define `doc` cy.get('im-page.hydrated im-button:eq(1)`).as('parent') cy.get('@parent').then($parent => { cy.get('button.success.outline:contains(Confirm)', { withinSubject: $parent })Debe activar shadowDOM globalmente para evitar perder cualquier parte que lo necesite.
// cypress.json { ... "includeShadowDom": true }#3 - simplemente haga una búsqueda simple de "Confirmar", ya que probablemente solo una cosa a la vez necesite confirmación.
cy.contains('button.success.outline', 'Confirm')