Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
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 answers
Answer question

0

replace the dictionary foreach with this

for (var i in dictionary) {
 tryCombinations(dictionary[i]);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!