e.g Site: https://www.jdsports.com.sg/product/white-adidas-ultraboost-21-primeblue-womens/16140531_jdsportssg/
const size = prompt('Size? ')
page.evaluate(size => {
const elements = [...document.querySelectorAll('btn btn-default ')];
const targetElement = elements.find(e => e.innerText.includes(size));
targetElement && targetElement.click();
}, size);
Im using puppeteer. At the moment i am trying to get the automation to click on the size based on the users input. Above is the current code I have but it isn't working.
heres how an product size button html:
<button data-e2e="pdp-productDetails-size" type="button" class="btn btn-default " data-price="SGD 260.00" data-sku="16140531_jdsportssg.2910757" data-upc="4064036981142" data-fulfilment-infopage="" data-pool=" 1 " data-stockcheckeravailable="0" data-stock="1" title="Select Size 4">
4
</button>
So im trying to click the button based on the text. Thank you in advance!