attribute automatically the port

This commit is contained in:
Lei PAN
2023-05-19 13:22:22 +02:00
parent 2685191be3
commit 7717a04b43
3 changed files with 40 additions and 18 deletions
+7 -8
View File
@@ -68,12 +68,13 @@ function logWithDevice(message, device) {
}
class CommandorPage {
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false) {
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false, port = 9000) {
this.contact = contact;
this.device = device;
this.mongoManager = mongoManager;
this.selectedStore = selectedStore;
this.choosedStore = selectedStore
this.choosedStore = selectedStore;
this.port = port;
this.isFillingFields = false;
this.isTerminated = false;
this.audioAnalyse = audioAnalyse;
@@ -86,12 +87,12 @@ class CommandorPage {
}
async loadPage(port) {
async loadPage() {
// Connect to the device.
log("loadPage() called");
log("loadPage() called, with port:" + this.port);
try {
this.browser = await puppeteer.connect({
browserWSEndpoint: 'ws://127.0.0.1:9002/devtools/browser',
browserWSEndpoint: "ws://127.0.0.1:" + this.port + "/devtools/browser",
headless: false, defaultViewport: null
})
this.page = await this.browser.newPage();
@@ -126,8 +127,6 @@ class CommandorPage {
log(e)
}
try {
// let element = await this.page.$(':nth-match(:text("rendezvousparis"), 1)')
// let element = await this.page.$(':nth-match(:text("rendezvousparis"), 1)')
const [button] = await this.page.$x("//a[contains(., 'rendezvousparis')]");
console.log("button is " + button)
if (button) {
@@ -365,7 +364,7 @@ class CommandorPage {
await delay(1000)
this.captchaSolver = new SolveCaptcha(page);
await this.captchaSolver.start((solution) => {
log("solution is: " + solution);
logWithDevice("solution is: " + solution, this.device);
if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) {
try {
if (!page.isClosed()) {