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

470
Visualizações
test something: selector needs to be typeof `string` or `function`

I want to write test on Visual Studio Code/Codeceptjs. My code is here in short :

let amazonWebKeys=require('./amazonKeys/amazonwebkeys.json');

module.exports = function() {
  return actor({

    buttons:{
       acceptcookie :  '//input[@id="sp-cc-accept"]'   //accept cookie button  
                  
    },

    getParemeters : function(keys){
      return amazonWebKeys[keys];
    },

    WebTest:function(){
      this.amOnPage(this.getParemeters("url")); //go to website
      this.click(this.buttons.acceptcookie); //accept cookie
   }  
  });
}

But error message. Why selector needs to be typeof 'string' or 'function. What can I do for this problem :

1) WebTest
       test something:
     selector needs to be typeof `string` or `function`
      at Browser.findElements (node_modules\webdriverio\build\utils\index.js:176:11)        
      at Browser.$$ (node_modules\webdriverio\build\commands\browser\$$.js:6:44)
      at Browser.wrapCommandFn (node_modules\@wdio\utils\build\shim.js:63:38)

And you can see at Scenario Steps that in click() is empty.

Scenario Steps:
  - I.click() at Actor.WebTest (.\steps_file.js:21:12)
  - I.amOnPage("https://www.amazon.com.tr/") at Actor.WebTest (.\steps_file.js:20:12) 

Thanks in advance

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Error in the locator. Try the locator name input [id = "sp-cc-accept"] without the @ symbol. Or just like this this.click('#sp-cc-accept'). And read more doc

about 4 years ago · Juan Pablo Isaza Relatório

0

I also faced the same error. I solved it with the following code:

module.exports = function () {

  let parameters = require('./Parameters/parameters.json');

  username = '//input[@id="username"]';
  password = '//input[@id="password"]';
  submitButton = '//button[@class="btn btn-primary"]';
  administration = '//li[@id="admin-menu"]';

  return actor({

    getEnviromentParameters: function (key) {
      return parameters[key];
    },

    login: function () {
      this.amOnPage(this.getEnviromentParameters('loginUrl'));
      this.fillField(`${username}`, 
        this.getEnviromentParameters('userName')
      );
      this.fillField(`${password}`, 
        this.getEnviromentParameters('password')
      );
      this.click(`${submitButton}`);
      this.waitForElement(`${submitButton}`, 5)
      this.seeElement(`${submitButton}`);
    }
  });
}
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