add timeout for goto

This commit is contained in:
2022-09-09 10:29:18 +02:00
parent 3557a2ed90
commit 28665cc017
3 changed files with 47 additions and 15 deletions
+21 -5
View File
@@ -71,7 +71,7 @@ class CommandorPage {
this.page.on("response", (response) => {
this.onResponse(response)
})
await this.page.goto(RDV_URL);
await this.page.goto(RDV_URL, {timeout: 90 * 1000});
//wait 10 mins
// Close the device.
@@ -215,10 +215,12 @@ class CommandorPage {
}
async onResponse(response) {
let rex = new RegExp(REGEX_RDV_URL)
if (rex.test(response.url)) {
console.log("rdv url found:" + response.url)
}
// let rex = new RegExp(REGEX_RDV_URL)
// console.log("onResponse with url:" + response.url())
// if (rex.test(response.url())) {
// console.log("rdv url found:" + response.url())
// await this.push_message_to_db(PublishType.SUCCESS, response.url())
// }
}
async push_message_to_queue(publishType) {
@@ -235,6 +237,20 @@ class CommandorPage {
this.isTerminated = true
}
async push_message_to_db(publishType, url) {
let splitedUrl = url.split("/");
let id = splitedUrl[splitedUrl.length - 1];
if (url === "https://rendezvousparis.hermes.com/client/welcome") {
return
}
// save to mongoDb
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, this.page.url(), 1, publishType);
reserve.source_from = this.device.model();
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
await delay(2 * 1000)
this.isTerminated = true
}
}