Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
Testcafe expect passes if await used but not if methods chained

Take this Testcafe code:

test
    .page('https://testsite.com')
    ('button hidden after clicked', async t => {
        await t
            .expect(await Selector('button.cc-banner__button-accept').visible).ok({ timeout: 5000 })
            .setNativeDialogHandler(() => true)
            .click(await Selector('button.cc-banner__button-accept'))
            .expect(await Selector('button.cc-banner__button-accept').visible).notOk({ timeout:1000 });

The above fails when Testcafe runs.

However, the code below passes:

test
    .page('https://testsite.com')
    ('button hidden after clicked', async t => {
        await t
            .expect(await Selector('button.cc-banner__button-accept').visible).ok({ timeout: 5000 })
            .setNativeDialogHandler(() => true)
            .click(await Selector('button.cc-banner__button-accept'));
        await t
            .expect(await Selector('button.cc-banner__button-accept').visible).notOk({ timeout:1000 });

Why is this? Any ideas?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

JS evaluates the real element value for Selector at the time of chain compiling. (JS works in this way). It means that the first test you evaluate calculates await Selector('button.cc-banner__button-accept').visible for the whole chain only once and then this value is used for checking. Since you get the value only once, the test fails as expected. You should remove await inside, before Selector inside assertions, as you can see in CLI warnings.

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda