I need help
Hi, I've created the agency bot for Iphone 16 Pro Max, but when the bot comes to the final page where it must click "Place Order" button, it doesn't click. Here's the code ` const puppeteer = require('puppeteer-extra');
const { executablePath } = require('puppeteer');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
const locateChrome = require('chrome-location');
async function givePage() {
const browser = await puppeteer.launch({headless: false, executablePath: locateChrome})
let page = await browser.newPage();
return page
}
async function run() {
let page = await givePage();
await page.goto(url_16);
await add_to_cart(page);
await shipping(page);
await payment(page);
}
async function add_to_cart(page) {
await smart_click_with_pause(page, "input[data-autom='dimensionScreensize6_3inch']", 0)
await smart_click_with_pause(page, "input[value='deserttitanium']", 0)
await smart_click_with_pause(page, "input[data-autom='dimensionCapacity256gb']", 500)
await smart_click_with_pause(page, "[id='noTradeIn_label']", 1500)
await smart_click_with_pause(page, "[data-autom='purchaseGroupOptionfullprice_price']", 1000)
await smart_click_with_pause(page, ".form-selector-title.rf-bfe-dimension-simfree", 1500)
await smart_click_with_pause(page, "[id='applecareplus_59_noapplecare_label']", 500)
await smart_click_with_pause(page, "[data-autom='add-to-cart']", 0)
}
async function shipping(page) {
await smart_click_with_pause(page, "button[name='proceed']", 0)
await smart_click_with_pause(page, "[id='shoppingCart.actions.navCheckoutOtherPayments']", 1000)
await smart_click_with_pause(page, "[id='signIn.guestLogin.guestLogin']", 0)
await smart_click_with_pause(page, "[id='rs-checkout-continue-button-bottom']", 500)
// Writing necessary information in input(first input only with waitForSelector)
selector = "input[id='checkout.shipping.addressSelector.newAddress.address.firstName']"
await page.waitForSelector(selector)
await page.type(selector, "Gevorg")
await page.type("input[name='lastName']", "Hovhannisyan")
await page.type("input[name='street']", "Tarontsi street 1st Lane 9")
// Zip code handling
const input = await page.$("input[name='postalCode']")
await input.click({clickCount: 3})
await input.type('20740')
await page.type("input[name='city']", "Yerevan")
await page.type("input[name='state']", "AL")
await page.type("input[name='emailAddress']", "hovhannigevorg@gmail.com")
await new Promise(r => setTimeout(r, 1000))
await page.type("input[name='fullDaytimePhone']", "5678945617")
await new Promise(r => setTimeout(r, 1000))
await page.click("#rs-checkout-continue-button-bottom")
}
async function payment(page) {
await smart_click_with_pause(page, "input[name='checkout.billing.billingOptions.selectBillingOption']", 500)
selector = "input[id='checkout.billing.billingOptions.selectedBillingOptions.creditCard.cardInputs.cardInput-0.cardNumber']"
await page.waitForSelector(selector)
await page.type(selector, "4929016078185747")
await page.type("[id='checkout.billing.billingOptions.selectedBillingOptions.creditCard.cardInputs.cardInput-0.expiration']", "10/28")
await page.type("[id='checkout.billing.billingOptions.selectedBillingOptions.creditCard.cardInputs.cardInput-0.securityCode']", "469")
await page.click("button[id='rs-checkout-continue-button-bottom']")
// Click Place Order button
await smart_click_with_pause(page, "button[id='rs-checkout-continue-button-bottom']", 0)
}
async function smart_click_with_pause(page, selector, pause) {
await page.waitForSelector(selector)
await page.evaluate((s) => document.querySelector(s).click(), selector)
await new Promise(r => setTimeout(r, pause))
}
run()
1
5 comments
Gevorg Hovhannisyan
2
I need help
Wifi Life
skool.com/wifi-life
A community of developers & entrepreneurs that provides exclusive material to develop coding based side hustles, land high paying tech jobs, and more.
Leaderboard (30-day)
powered by