Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e03bc59ca | |||
| 3e374f10fa | |||
| 1aec686c0b |
+17
-5
@@ -1,6 +1,10 @@
|
|||||||
const {exec} = require("child_process");
|
const {exec} = require("child_process");
|
||||||
|
|
||||||
DEVICE_REGEX = "(^[a-z0-9A-Z]*) .* model:([a-z0-9A-Z_]+)"
|
// DEVICE_REGEX = "(^[a-z0-9A-Z]*) .* model:([a-z0-9A-Z_]+)"
|
||||||
|
DEVICE_REGEX = "(^[a-z0-9A-Z-.:]*) .* model:([a-z0-9A-Z_]+)"
|
||||||
|
|
||||||
|
// DEVICE_REGEX = "(^[a-z0-9A-Z-]*) .* model:([a-z0-9A-Z_]+)"
|
||||||
|
|
||||||
|
|
||||||
async function devices() {
|
async function devices() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -23,10 +27,11 @@ async function devices() {
|
|||||||
const o = currentLine.split('\t')
|
const o = currentLine.split('\t')
|
||||||
findResult = currentLine.match(DEVICE_REGEX)
|
findResult = currentLine.match(DEVICE_REGEX)
|
||||||
console.log(findResult)
|
console.log(findResult)
|
||||||
try{
|
try {
|
||||||
result.push(new AndroidDevice(findResult[1], findResult[2]));}
|
result.push(new AndroidDevice(findResult[1], findResult[2]));
|
||||||
catch(e){
|
} catch (e) {
|
||||||
console.log(e)}
|
console.log(e)
|
||||||
|
}
|
||||||
console.log(result[i])
|
console.log(result[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,6 +62,13 @@ class AndroidDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async clearApp(packageName) {
|
||||||
|
let cmd = `adb -s ${this.serial} shell pm clear ${packageName}`
|
||||||
|
console.log("cmd is " + cmd)
|
||||||
|
await exec(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
shell(cmd) {
|
shell(cmd) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
exec("adb -s " + this.serial + " shell " + cmd, (error, stdout, stderr) => {
|
exec("adb -s " + this.serial + " shell " + cmd, (error, stdout, stderr) => {
|
||||||
|
|||||||
+17
-19
@@ -17,9 +17,9 @@ let includeMode = DeviceExcludeMode.ZERO
|
|||||||
let three_to_include = []
|
let three_to_include = []
|
||||||
let four_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
let four_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
||||||
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||||
// let appointment_to_include = ["ai9xv8hy599hvkee", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "fy65eqs4wkvcpf9h", "p7d6nbw8cu7duous", "fuljaueqguugf6pn", "fmiz5pa6rsx4u4ts"]
|
let appointment_to_include = ["bec11752", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ZY32GLBN5P", "ZY32GVW4NC", "becb6e99", "b41c1b72"]
|
||||||
let appointment_to_include = ["ai9xv8hy599hvkee", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "fy65eqs4wkvcpf9h", "p7d6nbw8cu7duous", "fmiz5pa6rsx4u4ts"]
|
|
||||||
let nine_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
let nine_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||||
|
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
|
||||||
attributedPorts = []
|
attributedPorts = []
|
||||||
const device_port_info = new Map();
|
const device_port_info = new Map();
|
||||||
startPort = 9000
|
startPort = 9000
|
||||||
@@ -63,7 +63,7 @@ async function needToBook(contact, mongoManager, alreadyBooked) {
|
|||||||
return needToBook
|
return needToBook
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBook(contactPojo, device, sender, selectedStore, alertBeep, port) {
|
async function startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
||||||
console.log(`model: ${device.model}`);
|
console.log(`model: ${device.model}`);
|
||||||
console.log(`serial: ${device.serial}`);
|
console.log(`serial: ${device.serial}`);
|
||||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
@@ -74,7 +74,7 @@ async function startBook(contactPojo, device, sender, selectedStore, alertBeep,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
||||||
let commandor = new CommandorPage(contactPojo, device, sender, mongoManager, selectedStore, alertBeep, port);
|
let commandor = new CommandorPage(contactPojo, device, sender, mongoManager, selectedStore, audioAnalyse, alertBeep, port);
|
||||||
//read contacts form excel
|
//read contacts form excel
|
||||||
return await commandor.loadPage();
|
return await commandor.loadPage();
|
||||||
} else {
|
} else {
|
||||||
@@ -82,14 +82,14 @@ async function startBook(contactPojo, device, sender, selectedStore, alertBeep,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startWithList(contacts, device, sender, selectedStore, alertBeep, port) {
|
async function startWithList(contacts, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
||||||
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
|
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
|
||||||
await duplicatedList.reduce(async (promise, contactPojo) => {
|
await duplicatedList.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, sender, selectedStore, alertBeep, port);
|
const contents = await startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
||||||
console.log(contents);
|
console.log(contents);
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,9 @@ function getContactListForDevice(device, allContactList) {
|
|||||||
return contactList;
|
return contactList;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', bindSerial = true, alertBeep = false) {
|
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
|
||||||
|
console.log("startBookWithNumbers() called, with alertBeep:" + alertBeep)
|
||||||
|
console.log("startBookWithNumbers() called, with audioAnalyse:" + audioAnalyse)
|
||||||
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
||||||
let contactList;
|
let contactList;
|
||||||
if (endNumber <= allContactList.length) {
|
if (endNumber <= allContactList.length) {
|
||||||
@@ -154,11 +156,13 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
} else {
|
} else {
|
||||||
attributedPort = startPort;
|
attributedPort = startPort;
|
||||||
startPort++;
|
startPort++;
|
||||||
let cmd = 'adb -s ' + device.serial + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
let cmd = 'adb -s \"' + device.serial + "\" forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||||
console.log("cmd is " + cmd);
|
console.log("cmd is " + cmd);
|
||||||
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
||||||
console.log('Output was:\n', output);
|
console.log('Output was:\n', output);
|
||||||
}
|
}
|
||||||
|
// start chrome
|
||||||
|
// device.shell("am start -n com.brave.browser/com.google.android.apps.chrome.Main")
|
||||||
return attributedPort
|
return attributedPort
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +192,12 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
} else if (includeMode === DeviceExcludeMode.APPOINTMENT) {
|
} else if (includeMode === DeviceExcludeMode.APPOINTMENT) {
|
||||||
device_to_excludes = appointment_to_include
|
device_to_excludes = appointment_to_include
|
||||||
} else if (includeMode === DeviceExcludeMode.ZERO) {
|
} else if (includeMode === DeviceExcludeMode.ZERO) {
|
||||||
device_to_excludes = ["127.0.0.1:6555"]
|
device_to_excludes = []
|
||||||
}
|
}
|
||||||
let filteredDeviceList;
|
|
||||||
if (includeMode === DeviceExcludeMode.ZERO) {
|
if (includeMode === DeviceExcludeMode.ZERO) {
|
||||||
filteredDeviceList = devices
|
filteredDeviceList = devices
|
||||||
} else {
|
} else
|
||||||
filteredDeviceList = devices.filter(device => device_to_excludes.includes(device.serial))
|
filteredDeviceList = devices.filter(device => device_to_excludes.includes(device.serial))
|
||||||
}
|
|
||||||
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
|
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
|
||||||
console.log("connected device number:" + filteredDeviceList.length)
|
console.log("connected device number:" + filteredDeviceList.length)
|
||||||
console.log("segmentNumber:" + segmentNumber)
|
console.log("segmentNumber:" + segmentNumber)
|
||||||
@@ -203,14 +205,10 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
for (let i = 0; i < filteredDeviceList.length; i++) {
|
for (let i = 0; i < filteredDeviceList.length; i++) {
|
||||||
let device = filteredDeviceList[i];
|
let device = filteredDeviceList[i];
|
||||||
let port = startForwordingForDevice(device)
|
let port = startForwordingForDevice(device)
|
||||||
let _contactList = []
|
let _contactList = listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1))
|
||||||
if (bindSerial) {
|
// let _contactList = getContactListForDevice(device, listWithoutBlackContact)
|
||||||
_contactList = getContactListForDevice(device, listWithoutBlackContact)
|
|
||||||
} else {
|
|
||||||
_contactList = listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1))
|
|
||||||
}
|
|
||||||
console.log("contactList: for device:" + device.serial + " has " + _contactList.length)
|
console.log("contactList: for device:" + device.serial + " has " + _contactList.length)
|
||||||
startWithList(_contactList, device, sender, selectedStore, alertBeep, port);
|
startWithList(_contactList, device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const OCRResult = {
|
|||||||
RECAPTCHA_FAILED: Symbol("RECAPTCHA_FAILED"),
|
RECAPTCHA_FAILED: Symbol("RECAPTCHA_FAILED"),
|
||||||
RECAPTCHA_ERROR: Symbol("RECAPTCHA_ERROR"),
|
RECAPTCHA_ERROR: Symbol("RECAPTCHA_ERROR"),
|
||||||
NO_INTERNET: Symbol("NO_INTERNET"),
|
NO_INTERNET: Symbol("NO_INTERNET"),
|
||||||
|
CHROME_NOTIFICATION: Symbol("CHROME_NOTIFICATION"),
|
||||||
BRAVE_SKIP: Symbol("BRAVE_SKIP"),
|
BRAVE_SKIP: Symbol("BRAVE_SKIP"),
|
||||||
BRAVE_PRIVACY: Symbol("BRAVE_PRIVACY"),
|
BRAVE_PRIVACY: Symbol("BRAVE_PRIVACY"),
|
||||||
BRAVE_PRIVACY_PUB: Symbol("BRAVE_PRIVACY_PUB"),
|
BRAVE_PRIVACY_PUB: Symbol("BRAVE_PRIVACY_PUB"),
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ const {exec} = require("child_process");
|
|||||||
const {openUrlWithAdb} = require("../utiles/CmdUtils");
|
const {openUrlWithAdb} = require("../utiles/CmdUtils");
|
||||||
const RequestDataPojo = require("../models/RequestDataPojo");
|
const RequestDataPojo = require("../models/RequestDataPojo");
|
||||||
const {REQUEST_DATA_OBJECT, TEST_QUEUE} = require("../queue/Sender");
|
const {REQUEST_DATA_OBJECT, TEST_QUEUE} = require("../queue/Sender");
|
||||||
const {page} = require("yarn/lib/cli");
|
|
||||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
|
||||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||||
const BLANK_URL = "about:blank"
|
const BLANK_URL = "about:blank"
|
||||||
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
||||||
@@ -51,12 +49,6 @@ function getRandom() {
|
|||||||
return Math.floor(Math.random() * 3);
|
return Math.floor(Math.random() * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomId() {
|
|
||||||
let _list = [PASSPORT_ID, EMAIL_ID, FIRST_NAME, LAST_NAME];
|
|
||||||
let index = Math.floor(Math.random() * _list.length);
|
|
||||||
return _list[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRandomWaitTime() {
|
function getRandomWaitTime() {
|
||||||
return getRandom() * 1000
|
return getRandom() * 1000
|
||||||
}
|
}
|
||||||
@@ -65,12 +57,6 @@ function log(message) {
|
|||||||
appointmentLogger.log({level: "info", message: message})
|
appointmentLogger.log({level: "info", message: message})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearApp(device, packageName) {
|
|
||||||
let cmd = `adb -s ${device.serial} shell pm clear ${packageName}`
|
|
||||||
logWithDevice("cmd is " + cmd, device)
|
|
||||||
await exec(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function exceutShellCmd(device, cmdToExecut) {
|
async function exceutShellCmd(device, cmdToExecut) {
|
||||||
let cmd = `adb -s ${device.serial} shell ${cmdToExecut}`
|
let cmd = `adb -s ${device.serial} shell ${cmdToExecut}`
|
||||||
logWithDevice("cmd is " + cmd, device)
|
logWithDevice("cmd is " + cmd, device)
|
||||||
@@ -84,7 +70,7 @@ function logWithDevice(message, device) {
|
|||||||
const searchTexts = ['hermes+rdv+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment']
|
const searchTexts = ['hermes+rdv+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment']
|
||||||
|
|
||||||
class CommandorPage {
|
class CommandorPage {
|
||||||
constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, alertBeep = false, port = 9000, shareCookiesWithRequests = true) {
|
constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false, port = 9000, shareCookiesWithRequests = true) {
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
// to remove this line if we want to use store in contacts
|
// to remove this line if we want to use store in contacts
|
||||||
// this.contact.store = DEFAULT_STORE
|
// this.contact.store = DEFAULT_STORE
|
||||||
@@ -408,12 +394,12 @@ class CommandorPage {
|
|||||||
// await page.focus(LAST_NAME);
|
// await page.focus(LAST_NAME);
|
||||||
await delay(getRandomWaitTime());
|
await delay(getRandomWaitTime());
|
||||||
console.log("will clear surname field");
|
console.log("will clear surname field");
|
||||||
// await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
// let field = document.getElementById("surname");
|
let field = document.getElementById("surname");
|
||||||
// if (field) {
|
if (field) {
|
||||||
// field.value = ""
|
field.value = ""
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
// await page.keyboard.type(this.contact.lastName);
|
// await page.keyboard.type(this.contact.lastName);
|
||||||
await page.evaluate((lastName) => {
|
await page.evaluate((lastName) => {
|
||||||
@@ -429,6 +415,7 @@ class CommandorPage {
|
|||||||
let field = document.getElementById("name");
|
let field = document.getElementById("name");
|
||||||
if (field) {
|
if (field) {
|
||||||
field.value = firstName;
|
field.value = firstName;
|
||||||
|
// field.value = ""
|
||||||
}
|
}
|
||||||
}, this.contact.firstName)
|
}, this.contact.firstName)
|
||||||
// await page.keyboard.type(this.contact.firstName);
|
// await page.keyboard.type(this.contact.firstName);
|
||||||
@@ -511,8 +498,10 @@ class CommandorPage {
|
|||||||
document.querySelector("#cgu").checked = true
|
document.querySelector("#cgu").checked = true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// await page.click(CGU_ID);
|
||||||
await delay(getRandomWaitTime());
|
await delay(getRandomWaitTime());
|
||||||
await page.focus(PROCESSING_ID);
|
await page.focus(PROCESSING_ID);
|
||||||
|
// await page.click(PROCESSING_ID)
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
if (!document.querySelector("#processing").checked) {
|
if (!document.querySelector("#processing").checked) {
|
||||||
document.querySelector("#processing").checked = true
|
document.querySelector("#processing").checked = true
|
||||||
@@ -585,15 +574,9 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async clickValid() {
|
async clickValid() {
|
||||||
logWithDevice("clickValid() called.", this.device);
|
logWithDevice("clickValid() called.", this.device);
|
||||||
for (let i = 0; i < 3; i++) {
|
await delay(getRandomWaitTime())
|
||||||
let _id_to_click = getRandomId()
|
|
||||||
await this.page.click(_id_to_click)
|
|
||||||
await delay(getRandomWaitTime())
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isFillingFields = false
|
this.isFillingFields = false
|
||||||
try {
|
try {
|
||||||
if (!this.page.isClosed()) {
|
if (!this.page.isClosed()) {
|
||||||
@@ -622,7 +605,7 @@ class CommandorPage {
|
|||||||
this.contact.firstName = raw.firstName
|
this.contact.firstName = raw.firstName
|
||||||
}
|
}
|
||||||
await this.page.evaluate(() => {
|
await this.page.evaluate(() => {
|
||||||
document.getElementsByTagName("button")[1].click();
|
document.getElementsByClassName("btn")[0].click();
|
||||||
})
|
})
|
||||||
if (this.firstStart) {
|
if (this.firstStart) {
|
||||||
this.disconnectBrowser();
|
this.disconnectBrowser();
|
||||||
@@ -837,11 +820,11 @@ class CommandorPage {
|
|||||||
this.isCountryChoosen = false;
|
this.isCountryChoosen = false;
|
||||||
this.isPhoneInput = false;
|
this.isPhoneInput = false;
|
||||||
this.isPasspordInput = false;
|
this.isPasspordInput = false;
|
||||||
await clearApp(this.device, this.browserPackageName)
|
await this.device.clearApp(this.browserPackageName)
|
||||||
|
// await clearApp(this.device, this.browserPackageName)
|
||||||
// await this.device.shell("pm clear " + this.browserPackageName)
|
// await this.device.shell("pm clear " + this.browserPackageName)
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
// await this.checkResultWithOcr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -896,11 +879,13 @@ class CommandorPage {
|
|||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
break;
|
break;
|
||||||
case OCRResult.SLIDING_CAPTCHA_REFRESH:
|
case OCRResult.SLIDING_CAPTCHA_REFRESH:
|
||||||
this.isTerminated = true;
|
await this.connect_to_browser(checkResult)
|
||||||
|
break;
|
||||||
|
case OCRResult.CHROME_NOTIFICATION:
|
||||||
|
await this.handleChromeNotification()
|
||||||
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
case OCRResult.SLIDING_CAPTCHA:
|
case OCRResult.SLIDING_CAPTCHA:
|
||||||
this.isAlreadyRefresh = true;
|
|
||||||
// await this.generateRandomActions()
|
|
||||||
logWithDevice("will call this.slidingCaptcha()", this.device)
|
logWithDevice("will call this.slidingCaptcha()", this.device)
|
||||||
await this.slidingCaptcha(async (isSuccessful) => {
|
await this.slidingCaptcha(async (isSuccessful) => {
|
||||||
logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
|
logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
|
||||||
@@ -913,7 +898,7 @@ class CommandorPage {
|
|||||||
await this.checkResultWithOcr()
|
await this.checkResultWithOcr()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await delay(5 * 1000)
|
// await delay(5 * 1000)
|
||||||
break;
|
break;
|
||||||
case OCRResult.FILL_FIELD:
|
case OCRResult.FILL_FIELD:
|
||||||
logWithDevice("FILL_FIELD", this.device)
|
logWithDevice("FILL_FIELD", this.device)
|
||||||
@@ -976,6 +961,8 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
await this.page.bringToFront();
|
await this.page.bringToFront();
|
||||||
|
// this.page = pages;
|
||||||
|
// this.page.await
|
||||||
await this.fillFields(this.page)
|
await this.fillFields(this.page)
|
||||||
await delay(2 * 1000);
|
await delay(2 * 1000);
|
||||||
}
|
}
|
||||||
@@ -1351,6 +1338,12 @@ class CommandorPage {
|
|||||||
await exec(cmd);
|
await exec(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async inputForDevice(device, text) {
|
||||||
|
let cmd = `adb -s ${device.serial} shell input text ${text}`
|
||||||
|
logWithDevice("cmd is " + cmd, this.device)
|
||||||
|
await exec(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
async clickOnConfirmBtn() {
|
async clickOnConfirmBtn() {
|
||||||
if (this.device.model === "CPH2219") {
|
if (this.device.model === "CPH2219") {
|
||||||
this.device.shell("input tap " + 900 + " " + 1532)
|
this.device.shell("input tap " + 900 + " " + 1532)
|
||||||
@@ -1452,6 +1445,8 @@ class CommandorPage {
|
|||||||
this.device.shell("input tap " + 490 + " " + 1910)
|
this.device.shell("input tap " + 490 + " " + 1910)
|
||||||
} else if (model === "RMX3151") {
|
} else if (model === "RMX3151") {
|
||||||
this.device.shell("input tap " + 492 + " " + 1960)
|
this.device.shell("input tap " + 492 + " " + 1960)
|
||||||
|
} else if (model === "Pixel"||model === "Pixel_2") {
|
||||||
|
this.device.shell("input tap " + 312 + " " + 1490)
|
||||||
} else if (model === "Mi Note 10") {
|
} else if (model === "Mi Note 10") {
|
||||||
this.device.shell("input tap " + 550 + " " + 1920)
|
this.device.shell("input tap " + 550 + " " + 1920)
|
||||||
} else if (model === "ONEPLUS_A6000") {
|
} else if (model === "ONEPLUS_A6000") {
|
||||||
@@ -1549,6 +1544,16 @@ class CommandorPage {
|
|||||||
await this.tapForDevice(this.device, 100, 400)
|
await this.tapForDevice(this.device, 100, 400)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async handleChromeNotification() {
|
||||||
|
let model = this.device.model
|
||||||
|
if (model === "KB2003" || model === "22041219PG" || model === "DE2117" || model === "21091116C") {
|
||||||
|
await this.tapForDevice(this.device, 545, 1448)
|
||||||
|
} else if (model === "sdk_gphone64_arm64") {
|
||||||
|
await this.tapForDevice(this.device, 484, 1723)
|
||||||
|
} else
|
||||||
|
await this.tapForDevice(this.device, 100, 400)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module
|
module
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ const NO_INTERNET_FR_2 = "Aucun accès à Internet"
|
|||||||
const BRAVE_VPN_SKIP = "Pare-feu + VPN Brave"
|
const BRAVE_VPN_SKIP = "Pare-feu + VPN Brave"
|
||||||
const MESSAGE_URL_VALIDATION_FR = "Vous recevrez un email de validation"
|
const MESSAGE_URL_VALIDATION_FR = "Vous recevrez un email de validation"
|
||||||
const MESSAGE_URL_VALIDATION_FR_2 = "Merci de votre intérêt pour notre Maison"
|
const MESSAGE_URL_VALIDATION_FR_2 = "Merci de votre intérêt pour notre Maison"
|
||||||
const MESSAGE_URL_VALIDATION_FR_3 = "vous allez recevoir un courriel de notre part"
|
|
||||||
const SSL_CERT_ERROR = " Votre connexion n'est pas privée"
|
const SSL_CERT_ERROR = " Votre connexion n'est pas privée"
|
||||||
const MESSAGE_URL_VALIDATION_EN = "Please click on the link we sent by email"
|
const MESSAGE_URL_VALIDATION_EN = "Please click on the link we sent by email"
|
||||||
const WRONG_PHONE_NUMBER = "Veuillez renseigner vote numéro de téléphone"
|
const WRONG_PHONE_NUMBER = "Veuillez renseigner vote numéro de téléphone"
|
||||||
@@ -48,7 +47,7 @@ const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour"
|
|||||||
const MESSAGE_FILL_FIELD_FR_2 = "des champs de données doivent étre complétés"
|
const MESSAGE_FILL_FIELD_FR_2 = "des champs de données doivent étre complétés"
|
||||||
const MESSAGE_FILL_FIELD_FR_3 = "Sans préféré"
|
const MESSAGE_FILL_FIELD_FR_3 = "Sans préféré"
|
||||||
const MESSAGE_FILL_FIELD_FR_4 = "Magasin préféré"
|
const MESSAGE_FILL_FIELD_FR_4 = "Magasin préféré"
|
||||||
const MESSAGE_FILL_FIELD_FR_5 = "demande de rendez-vous pour le"
|
const MESSAGE_FILL_FIELD_FR_5 = "email vous sera envoyé pour vous"
|
||||||
const MESSAGE_FILL_FIELD_FR_6 = "Prénom* Téléphone*"
|
const MESSAGE_FILL_FIELD_FR_6 = "Prénom* Téléphone*"
|
||||||
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
|
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
|
||||||
const WELCOME_MESSAGE_FR_2 = "Chrome Connectez-vous"
|
const WELCOME_MESSAGE_FR_2 = "Chrome Connectez-vous"
|
||||||
@@ -61,6 +60,7 @@ const PAGE_OPTIMIZATION_CHROME_FR_4 = "de nouvelles fonctionnalités"
|
|||||||
const PAGE_OPTIMIZATION_CHROME_FR_5 = "Avec la mesure des performance"
|
const PAGE_OPTIMIZATION_CHROME_FR_5 = "Avec la mesure des performance"
|
||||||
const PAGE_OPTIMIZATION_CHROME_FR_7 = "Les annonces suggérées par les"
|
const PAGE_OPTIMIZATION_CHROME_FR_7 = "Les annonces suggérées par les"
|
||||||
const PAGE_OPTIMIZATION_CHROME_FR_8 = "Chrome estime vos centres"
|
const PAGE_OPTIMIZATION_CHROME_FR_8 = "Chrome estime vos centres"
|
||||||
|
const CHROME_NOTIFICATION = "Les notifications de Chrome"
|
||||||
const ONLINE_APPOINTMENT = "Online Appointment"
|
const ONLINE_APPOINTMENT = "Online Appointment"
|
||||||
const CONFIRM_RESEND_FORM_FR = "Confirmer le nouvel envoi"
|
const CONFIRM_RESEND_FORM_FR = "Confirmer le nouvel envoi"
|
||||||
const CLOSED_MESSAGE_FR = "Depuis plus de 130 ans"
|
const CLOSED_MESSAGE_FR = "Depuis plus de 130 ans"
|
||||||
@@ -101,10 +101,7 @@ class OCRChecker {
|
|||||||
try {
|
try {
|
||||||
let result = await findText(fileName)
|
let result = await findText(fileName)
|
||||||
console.log(result)
|
console.log(result)
|
||||||
if (result.includes(MESSAGE_URL_VALIDATION_EN)
|
if (result.includes(MESSAGE_URL_VALIDATION_EN) || result.includes(MESSAGE_URL_VALIDATION_FR) || result.includes(MESSAGE_URL_VALIDATION_FR_2)) {
|
||||||
|| result.includes(MESSAGE_URL_VALIDATION_FR)
|
|
||||||
|| result.toLowerCase().includes(MESSAGE_URL_VALIDATION_FR_3)
|
|
||||||
|| result.includes(MESSAGE_URL_VALIDATION_FR_2)) {
|
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.SUCCESS
|
return OCRResult.SUCCESS
|
||||||
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
||||||
@@ -113,6 +110,9 @@ class OCRChecker {
|
|||||||
} else if (result.includes(PUSH_NOTIFICATION_1)) {
|
} else if (result.includes(PUSH_NOTIFICATION_1)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BRAVE_PUSH_NOTIFICATION
|
return OCRResult.BRAVE_PUSH_NOTIFICATION
|
||||||
|
} else if (result.includes(CHROME_NOTIFICATION)) {
|
||||||
|
await this.deleteFile(fileName)
|
||||||
|
return OCRResult.CHROME_NOTIFICATION
|
||||||
} else if (result.includes(CHOOSE_POSITION_GOOGLE_FR)) {
|
} else if (result.includes(CHOOSE_POSITION_GOOGLE_FR)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.CHOOSE_POSITION
|
return OCRResult.CHOOSE_POSITION
|
||||||
@@ -125,7 +125,7 @@ class OCRChecker {
|
|||||||
} else if (result.includes(WRONG_PHONE_NUMBER)) {
|
} else if (result.includes(WRONG_PHONE_NUMBER)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.WRONG_PHONE_NUMBER
|
return OCRResult.WRONG_PHONE_NUMBER
|
||||||
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.toLowerCase().includes(MESSAGE_FILL_FIELD_FR_5) || result.includes(MESSAGE_FILL_FIELD_FR_6)) {
|
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.includes(MESSAGE_FILL_FIELD_FR_5) || result.includes(MESSAGE_FILL_FIELD_FR_6)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.FILL_FIELD
|
return OCRResult.FILL_FIELD
|
||||||
} else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
} else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
||||||
@@ -152,6 +152,9 @@ class OCRChecker {
|
|||||||
} else {
|
} else {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
}
|
}
|
||||||
|
// await this.deleteFile(screenShot)
|
||||||
|
// if (result.includes("rac"))
|
||||||
|
// return OCRResult.SLIDING_CAPTCHA_REFRESH
|
||||||
return OCRResult.SLIDING_CAPTCHA
|
return OCRResult.SLIDING_CAPTCHA
|
||||||
} else if (result.includes(SLIDING_CAPTCHA_RETRY_FR)
|
} else if (result.includes(SLIDING_CAPTCHA_RETRY_FR)
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user