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

471
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 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