can cancel promis
This commit is contained in:
@@ -12,17 +12,48 @@ function delay(delayInms) {
|
||||
}
|
||||
|
||||
const mongoManager = new MongoManager();
|
||||
mongoManager.connect()
|
||||
|
||||
let excelUtil = new ExcelUtil();
|
||||
let contactList = excelUtil.readContacts();
|
||||
(async () => {
|
||||
|
||||
// Connect to the device.
|
||||
const [device] = await android.devices();
|
||||
|
||||
async function startBook(contactPojo, device) {
|
||||
console.log(`Model: ${device.model()}`);
|
||||
console.log(`Serial: ${device.serial()}`);
|
||||
let commandor = new CommandorPage(contactList[3], device, mongoManager);
|
||||
//read contacts form excel
|
||||
await commandor.loadPage();
|
||||
// Take screenshot of the whole device.
|
||||
})();
|
||||
let commandor = new CommandorPage(contactPojo, device, mongoManager);
|
||||
//read contacts form excel
|
||||
return await commandor.loadPage();
|
||||
}
|
||||
|
||||
mongoManager.connect().then(r => console.log("mongo connected"))
|
||||
|
||||
async function printFiles() {
|
||||
let devices = await android.devices();
|
||||
await contactList.reduce(async (promise, contactPojo) => {
|
||||
// This line will wait for the last async function to finish.
|
||||
// The first iteration uses an already resolved Promise
|
||||
// so, it will immediately continue.
|
||||
await promise;
|
||||
const contents = await startBook(contactPojo, devices[0]);
|
||||
console.log(contents);
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
(async () => {
|
||||
printFiles()
|
||||
})()
|
||||
|
||||
|
||||
// android.devices().then((device_list) => {
|
||||
// contactList.forEach((contactPojo) => {
|
||||
// device_list.forEach((device) => {
|
||||
// (async () => {
|
||||
// await startBook(contactPojo, device)
|
||||
// })()
|
||||
// }
|
||||
// )
|
||||
// }
|
||||
// )
|
||||
// })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user