0
我設法讓我的代碼等待提示,但由於某種原因它不會在收到提示後繼續。輸出是:與提示的木偶,忽略功能的其餘部分
prompt: password:
Command-line input received:
password: password
下面的代碼:
const puppeteer = require('puppeteer');
const prompt = require('prompt');
const url = 'some url';
var schema = {
properties: {
password: {
hidden: true
}
}
};
prompt.start();
(async() => {
var result = await new Promise(function (resolve, reject) {
return prompt.get(schema, function (err, result) {
console.log('Command-line input received:');
console.log(' password: ' + result.password);
return result;
})
});
console.log(result);
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto(url);
/* truncated */
})();
我會在訪問代碼時回覆您 –