can start booking with gui
This commit is contained in:
@@ -36,3 +36,7 @@ adb -s 835dca3e shell am start -n com.android.chrome/com.google.android.apps.chr
|
|||||||
adb -s d54e946 shell pm clear com.android.chrome
|
adb -s d54e946 shell pm clear com.android.chrome
|
||||||
adb -s d54e946 shell am set-debug-app --persistent com.android.chrome
|
adb -s d54e946 shell am set-debug-app --persistent com.android.chrome
|
||||||
adb -s d54e946 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
adb -s d54e946 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|
||||||
|
adb -s 751005221815 shell pm clear com.android.chrome
|
||||||
|
adb -s 751005221815 shell am set-debug-app --persistent com.android.chrome
|
||||||
|
adb -s 751005221815 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const {app, BrowserWindow, ipcMain} = require('electron')
|
const {app, BrowserWindow, ipcMain} = require('electron')
|
||||||
|
const startBookWithNumbers = require('./src/appointment')
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const createWindow = () => {
|
const createWindow = () => {
|
||||||
@@ -34,6 +35,9 @@ function startBook(startNumber, endNumber, selectedStore) {
|
|||||||
console.log("startNumber: " + startNumber)
|
console.log("startNumber: " + startNumber)
|
||||||
console.log("endNumber: " + endNumber)
|
console.log("endNumber: " + endNumber)
|
||||||
console.log("selectedStore: " + selectedStore)
|
console.log("selectedStore: " + selectedStore)
|
||||||
|
startBookWithNumbers(startNumber, endNumber, selectedStore).then(() => {
|
||||||
|
console.log("stop")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,3 @@ const {contextBridge, ipcRenderer} = require('electron')
|
|||||||
contextBridge.exposeInMainWorld('appointment', {
|
contextBridge.exposeInMainWorld('appointment', {
|
||||||
startBook: (startNumber, endNumber, selectedStore) => ipcRenderer.send('start-book', startNumber, endNumber, selectedStore)
|
startBook: (startNumber, endNumber, selectedStore) => ipcRenderer.send('start-book', startNumber, endNumber, selectedStore)
|
||||||
})
|
})
|
||||||
|
|
||||||
//
|
|
||||||
// const startBook = () => {
|
|
||||||
// console.log("开始约会 " + "store:" + selectedStore)
|
|
||||||
// window.appointment.startBook(startNumber, endNumber, selectedStore)
|
|
||||||
// // startBookWithNumbers()
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const {_android: android} = require('playwright');
|
const {_android: android} = require('playwright');
|
||||||
const ExcelUtil = require("./src/excel/ExcelUtil");
|
const ExcelUtil = require("./excel/ExcelUtil");
|
||||||
const CommandorPage = require("./src/workers/CommandorPage");
|
const CommandorPage = require("./workers/CommandorPage");
|
||||||
const {MongoManager, formatDate} = require("./src/workers/mongo_manager");
|
const {MongoManager, formatDate} = require("./workers/mongo_manager");
|
||||||
|
|
||||||
const mongoManager = new MongoManager();
|
const mongoManager = new MongoManager();
|
||||||
|
|
||||||
@@ -34,11 +34,11 @@ async function needToBook(contact, mongoManager) {
|
|||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBook(contactPojo, device) {
|
async function startBook(contactPojo, device, selectedStore) {
|
||||||
console.log(`Model: ${device.model()}`);
|
console.log(`Model: ${device.model()}`);
|
||||||
console.log(`Serial: ${device.serial()}`);
|
console.log(`Serial: ${device.serial()}`);
|
||||||
if (await needToBook(contactPojo, mongoManager)) {
|
if (await needToBook(contactPojo, mongoManager)) {
|
||||||
let commandor = new CommandorPage(contactPojo, device, mongoManager);
|
let commandor = new CommandorPage(contactPojo, device, mongoManager, selectedStore);
|
||||||
//read contacts form excel
|
//read contacts form excel
|
||||||
return await commandor.loadPage();
|
return await commandor.loadPage();
|
||||||
} else {
|
} else {
|
||||||
@@ -46,26 +46,32 @@ async function startBook(contactPojo, device) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startWithList(contacts, device) {
|
async function startWithList(contacts, device, selectedStore) {
|
||||||
await contacts.reduce(async (promise, contactPojo) => {
|
await contacts.reduce(async (promise, contactPojo) => {
|
||||||
// This line will wait for the last async function to finish.
|
// This line will wait for the last async function to finish.
|
||||||
// The first iteration uses an already resolved Promise
|
// The first iteration uses an already resolved Promise
|
||||||
// so, it will immediately continue.
|
// so, it will immediately continue.
|
||||||
await promise;
|
await promise;
|
||||||
const contents = await startBook(contactPojo, device);
|
const contents = await startBook(contactPojo, device, selectedStore);
|
||||||
console.log(contents);
|
console.log(contents);
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBookWithNumbers(startNumber, endNumber) {
|
async function startBookWithNumbers(startNumber, endNumber, selectedStore) {
|
||||||
let contactList = excelUtil.readContacts();
|
let allContactList = excelUtil.readContacts();
|
||||||
|
let contactList;
|
||||||
|
if (endNumber <= allContactList.length) {
|
||||||
|
contactList = allContactList.slice(startNumber, endNumber);
|
||||||
|
} else {
|
||||||
|
contactList = allContactList;
|
||||||
|
}
|
||||||
mongoManager.connect().then(r => {
|
mongoManager.connect().then(r => {
|
||||||
filterAlreadyBookedContacts(contactList).then(listToBook => {
|
filterAlreadyBookedContacts(contactList).then(listToBook => {
|
||||||
console.log(listToBook.length)
|
console.log("number of contacts to book:" + listToBook.length)
|
||||||
android.devices().then((devices) => {
|
android.devices().then((devices) => {
|
||||||
let segmentNumber = listToBook.length / devices.length;
|
let segmentNumber = listToBook.length / devices.length;
|
||||||
for (let i = 0; i < devices.length; i++) {
|
for (let i = 0; i < devices.length; i++) {
|
||||||
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i]);
|
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -30,6 +30,7 @@ const TOO_MANY_REQUEST_ERROR_MESSAGE_FR = "Suite à un trop grand nombre de dema
|
|||||||
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
||||||
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
||||||
REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
||||||
|
const DEFAULT_STORE = 'faubourg';
|
||||||
|
|
||||||
function delay(delayInms) {
|
function delay(delayInms) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -48,10 +49,11 @@ function getRandomWaitTime() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CommandorPage {
|
class CommandorPage {
|
||||||
constructor(contact, device, mongoManager) {
|
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE) {
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
this.device = device;
|
this.device = device;
|
||||||
this.mongoManager = mongoManager;
|
this.mongoManager = mongoManager;
|
||||||
|
this.selectedStore = selectedStore;
|
||||||
this.isFillingFields = false;
|
this.isFillingFields = false;
|
||||||
this.isTerminated = false;
|
this.isTerminated = false;
|
||||||
}
|
}
|
||||||
@@ -198,7 +200,7 @@ class CommandorPage {
|
|||||||
await page.locator(PREFER_STORE).focus()
|
await page.locator(PREFER_STORE).focus()
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
await page.click(PREFER_STORE);
|
await page.click(PREFER_STORE);
|
||||||
await page.selectOption(PREFER_STORE, "faubourg");
|
await page.selectOption(PREFER_STORE, this.selectedStore);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user