Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda