From ff544bd8ee47b12b96a79022044e9ec99f35618a Mon Sep 17 00:00:00 2001 From: HAJonSoft Date: Sat, 4 Jan 2025 20:20:22 +0200 Subject: [PATCH] owl save and continue later (#242) * documents error handling * save and continue later --- package.json | 2 +- src/nsh.js | 56 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index bbdb4bc..80a2e94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hajonsoft-eagle", - "version": "2.7.0", + "version": "2.7.1", "description": "HAJonSoft node app to submit passengers to visa systems", "main": "index.js", "scripts": { diff --git a/src/nsh.js b/src/nsh.js index ce72f31..9b9b52a 100644 --- a/src/nsh.js +++ b/src/nsh.js @@ -382,8 +382,8 @@ async function pageContentHandler(currentConfig) { emailCodeCounter = 0; clearTimeout(timerHandler); // stop captcha attempts - registerCaptchaAbortController.abort(); - loginCaptchaAbortController.abort(); + // registerCaptchaAbortController.abort(); + // loginCaptchaAbortController.abort(); await page.waitForSelector( "#otp-inputs > input.form-control.signup-otp.me-1", @@ -609,12 +609,16 @@ async function pageContentHandler(currentConfig) { await page.evaluate(() => { window.scrollTo(0, document.body.scrollHeight); }); - // if (passenger.nationality.code === data.system.country.code) { - // await page.waitFor(1000); - // await page.click( - // "body > main > div.system > div > div.system-content.p-3 > form > div.d-flex.align-items-md-center.justify-content-md-between.px-3.mb-4.flex-wrap.flex-column-reverse.flex-md-row > div.d-flex.justify-content-end.order-md-2.next-buttons > div > button.btn.btn-main.btn-next.mb-3" - // ); - // } + // choose city 3ccb61fc-5947-4469-915f-884ed1b9666d + await util.commit( + page, + [{ + selector: "#PassportSummaryViewModel_CityId", + value: () => "#PassportSummaryViewModel_CityId" + }], + {} + ) + { } break; case "summary2": await checkIfNotChecked("#DeportedFromAnyCountryBeforeNo"); @@ -727,6 +731,39 @@ async function pageContentHandler(currentConfig) { ) { clicked[passenger.passportNumber + "documents"] = true; await uploadDocuments(util.getSelectedTraveler()); + try { + const modalContentSelector = "body > div.swal-overlay.swal-overlay--show-modal > div > div.swal-text"; + await page.waitForSelector(modalContentSelector, { + timeout: 5000, + }); + const modalContent = await page.$eval( + modalContentSelector, + (e) => e.textContent + ); + if (modalContent) { + console.log(modalContent) + await kea.updatePassenger( + data.system.accountId, + passenger.passportNumber, + { + "submissionData.nsk.status": "Rejected", + "submissionData.nsk.rejectionReason": modalContent, + } + ); + await util.clickWhenReady("body > div.swal-overlay.swal-overlay--show-modal > div > div.swal-footer > div > button", page) + } + // TODO: Check what to do in case of error and headless, please notice the headless logic below + } catch { } + } + if (global.headless) { + // wait for 5 seconds + await new Promise(resolve => setTimeout(resolve, 5000)); + await page.click("#save-btn") + console.log("Saved to continue later.") + // wait for 5 seconds + await new Promise(resolve => setTimeout(resolve, 5000)); + await page.browser().close(); + process.exit(0) } // Do you have residence Id // #HaveValidResidencyNo @@ -1689,5 +1726,8 @@ module.exports = { send }; // 4- implement new captcha mouse click // 5- add scroll to element in config and scroll to it // TODO: Chunk-ing +// Phase 1 +// Click Save and continue later +// Phase 2 // 1- Take all the travellers and divide them into leader and its companions // 2- for each leader and the associated companion get a machine to register them \ No newline at end of file