Better handling and logging

This commit is contained in:
2023-05-21 01:21:33 +02:00
parent 87f442764a
commit cb4ae768bd
3 changed files with 17 additions and 17 deletions

View File

@@ -86,7 +86,8 @@ async function createAccount(driver) {
await VerificationCodeInput.sendKeys(`${code}`);
}
catch (err) {
return;
await driver.quit();
return 1;
}
await driver.findElement(By.id('iOptinEmail')).click();
await driver.sleep(clickTime);
@@ -96,24 +97,16 @@ async function createAccount(driver) {
const source = await driver.getPageSource();
if (source.includes('Phone number')) {
console.log('Ip usage exceeded please switch IP');
// await disconnect();
await driver.quit();
const answer = await questionAsync('Would you like to continue? [y/n] ');
if (answer.toLowerCase() === 'n' || answer.toLowerCase() === 'no') {
console.log('Program stopped.');
await driver.quit();
process.exit(0);
}
else {
console.log('Continuing...');
await new Promise((resolve) => setTimeout(resolve, 1000));
// try {
// await connect();
// }
// catch (error) {
// console.error('Error connecting to mail server:', error);
// await driver.quit();
// process.exit(0);
// }
return 1;
}
}
else {
@@ -198,12 +191,14 @@ async function createAccount(driver) {
await driver.findElement(By.xpath('//span[contains(text(), "SET AS GOAL")]')).click();
await driver.sleep(2000);
await driver.quit();
return 0;
}
}
finally {
await driver.quit();
catch (err) {
return 1;
}
return;
}
module.exports = { createAccount };