Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
Testcafe AWS Cognito Login - Entrada no reconocida como visible

Estoy creando un sitio web y, como parte, se utiliza un inicio de sesión de AWS Cognito. Ahora quería escribir la prueba e2e en TestCafe, pero estoy luchando para que el formulario de inicio de sesión de Cognito funcione con TestCafe.

Cuando no se encuentra ninguna sesión, la página lo redirigirá a la página de "inicio de sesión" de AWS Cognito OAuth adecuada.

El siguiente código de prueba fallará

 import { Selector } from 'testcafe'; const config = {...}; test('Logging in', async t => { await t .typeText(Selector('input#signInFormUsername'), config.credentials.username) .typeText('input#signInFormPassword', config.credentials.password) .click('input[type=submit]'); });

con el error

 The element that matches the specified selector is not visible. ... 21 |}); 22 | 23 |//then create a test and place your code there 24 |test('Logging in', async t => { 25 | await t > 26 | .typeText(Selector('input#signInFormUsername'), config.credentials.username) 27 | .typeText('input#signInFormPassword', config.credentials.password) 28 | .click('input[type=submit]'); 29 |}); 30 |

Y de hecho, cuando ejecuto la prueba

 test('Logging in', async t => { const usernameInputVisible = usernameInputSelector.visible; await t.expect(usernameInputVisible).ok(); });

falla

Lo curioso es que a) en realidad veo el elemento yb) no es ni display: none ni visibility: hidden como se describe aquí debajo de visible.

El elemento existe según TestCafe ya que lo siguiente no falla:

 test('Logging in', async t => { const usernameInputExists = usernameInputSelector.exists; await t.expect(usernameInputExists).ok(); });

¿Que me estoy perdiendo aqui? ¿Cómo hago para que TestCafe funcione con la página de inicio de sesión de AWS Cognito OAuth?

Configuración:

 $ sw_vers ProductName: macOS ProductVersion: 12.2.1 BuildVersion: 21D62 $ node --version v16.14.0 $ testcafe --version 1.18.4

Probé este comportamiento con chrome , firefox y safari .

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La respuesta simple es que hay dos entradas para cada ID, por ejemplo, signInFormUsername , y así obtenemos varios elementos que coinciden con cada selector. El segundo elemento de cada selector es invisible ( display: none ). La solución es filtrar los elementos invisibles:

 test('Logging in', async t => { await t .typeText(Selector('input#signInFormUsername').filterVisible(), config.credentials.username) .typeText(Selector('input#signInFormPassword').filterVisible(), config.credentials.password) .click(Selector('input[type=submit]').filterVisible()); });

No estoy 100% convencido de que esta sea una buena solución.

La pregunta original y la solución se pueden encontrar aquí .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!