I am trying to make a bot, and I need to select a size. For now, i’m just going to select 11. How would I do this, since all of the buttons have the same class?
I have tried to select the data-testid, but i’m pretty new at puppeteer and node.js in general, so it’s been a little hard.
const pt = require('puppeteer')
const url = 'https://stockx.com/buy/air-jordan-1-retro-high-og-chicago-reimagined-lost-and-found'
async function initBrowser(){
const browser = await pt.launch({headless:false, defaultViewport: null, slowMo:10});
const page = await browser.newPage();
await page.goto(url,{waitUntil: 'networkidle0'});
return page;
}
async function selectSize(){
const page = await initBrowser();
await page.$eval("div[data-testid='size-11'" , form => form.click() );
}
async function checkout(){
await selectSize();
await page.setViewport({width: 1920, height: 1080})
await page.screenshot({path: 'test.png'})
}
checkout();
What ends up happening is this:
Error: Error: failed to find element matching selector "div[data-testid="#size-11"]"
at CDPElementHandle.$eval (*filepath*)
at async selectSize (*filepath*)
at async checkout (*filepath*)