致电功能多个时间nodejs
我有以下代码,可以在网站上插入密码。
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++;
}
如果我启动脚本,它将在浏览器中粘贴第一个密码。我现在想从数组中输入每个密码。
为此,我的想法是这样的:
dictionary.forEach(element => tryCombinations(element));
有人知道,为什么它不起作用?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用这个替换词典
replace the dictionary foreach with this