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

210
Vistas
Passing string arguments to TestCafe Selector in page model

I have a problem similar to link, I think in that link guys are using typescript files. I have defined selectors in the js files, I tried to do it this way:

class Page {
   constructor(sampleText){
       this.optionsButton = Selector('#options').withText(sampleText);
   }
}
export default new Page();

but when I try to call selector from test file

test('sampleTest', async t=> {
    await t.click(Page.optionsButton('sometext');
)}

I got an error:

ERROR Cannot prepare tests due to the following error: The "text" argument (undefined) is not of expected type (string or a regular expression).

How to solve this issue ?

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

0

optionsButton is a property and its value is defined using the constructor so the parameter can only be passed at the moment you create the object like this:

new Page('sometext');

It would be better if you write a method in the Page class that returns the selector based on a parameter:

class Page {
  optionsButton(opt) {
    return Selector('#options').withText(opt);
  }
}

export default new Page();
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