minor changes
parent
3637da66db
commit
7ac889e538
|
@ -237,8 +237,8 @@ const emailUtils = require("./email-utils");
|
||||||
* Select shipping date
|
* Select shipping date
|
||||||
*/
|
*/
|
||||||
const selectShippingDate = async (page) => {
|
const selectShippingDate = async (page) => {
|
||||||
// wait for 5 seconds
|
try {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5 * 1000));
|
console.log("Selecting Dates")
|
||||||
// select shipping date
|
// select shipping date
|
||||||
const shippingDateSelector =
|
const shippingDateSelector =
|
||||||
'div[id="packageList[0].trackingInfoList[0].shipDate"] input:first-of-type';
|
'div[id="packageList[0].trackingInfoList[0].shipDate"] input:first-of-type';
|
||||||
|
@ -246,20 +246,22 @@ const emailUtils = require("./email-utils");
|
||||||
await page.click(shippingDateSelector);
|
await page.click(shippingDateSelector);
|
||||||
|
|
||||||
// wait for 5 seconds
|
// wait for 5 seconds
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5 * 1000));
|
await new Promise((resolve) => setTimeout(resolve, 2 * 1000));
|
||||||
|
|
||||||
// select shipping date
|
// select shipping date
|
||||||
const shippingDateOptionSelector =
|
const shippingDateOptionSelector =
|
||||||
"body > div.PT_outerWrapper_123.PP_outerWrapper_123.ST_dropdown_123.ST_largeDropdown_123.PT_dropdown_123.PT_portalBottomLeft_123.PT_inCustom_123.PP_dropdown_123 > div > div > div > div > div > div:nth-child(1) > ul > li.cIL_item_123.cIL_large_123.cIL_highlight_123.ST_itemRendererLabel_123";
|
"body > div.PT_outerWrapper_123.PP_outerWrapper_123.ST_dropdown_123.ST_largeDropdown_123.PT_dropdown_123.PT_portalBottomLeft_123.PT_inCustom_123.PP_dropdown_123 > div > div > div > div > div > div:nth-child(1) > ul > li.cIL_item_123.cIL_large_123.cIL_highlight_123.ST_itemRendererLabel_123";
|
||||||
await page.waitForSelector(shippingDateOptionSelector);
|
await page.waitForSelector(shippingDateOptionSelector);
|
||||||
await page.click(shippingDateOptionSelector);
|
await page.click(shippingDateOptionSelector);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Capture response
|
* Capture response
|
||||||
*/
|
*/
|
||||||
const checkShippingRates = async (page, timer) => {
|
const checkShippingRates = async (page, timer) => {
|
||||||
await selectShippingDate(page);
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// Timeout mechanism to resolve with an empty list after 5 seconds
|
// Timeout mechanism to resolve with an empty list after 5 seconds
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
|
@ -590,10 +592,12 @@ const emailUtils = require("./email-utils");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const responsePromise = checkShippingRates(page, 10_000);
|
|
||||||
// button exist
|
// button exist
|
||||||
await buyShippingBtn.click();
|
await buyShippingBtn.click();
|
||||||
console.log("Clicking on Buy Shipping Button");
|
console.log("Clicking on Buy Shipping Button");
|
||||||
|
await selectShippingDate(page);
|
||||||
|
const responsePromise = checkShippingRates(page, 10_000);
|
||||||
|
|
||||||
let orderShippingRates = await responsePromise;
|
let orderShippingRates = await responsePromise;
|
||||||
|
|
||||||
|
@ -628,7 +632,8 @@ const emailUtils = require("./email-utils");
|
||||||
rates = [];
|
rates = [];
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emailUtils.notify(`Sync Temu Orders Shipping Rates`, e.message);
|
console.log(e);
|
||||||
|
//emailUtils.notify(`Sync Temu Orders Shipping Rates`, e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue