I need to know how can we type a string in input box using puppeteer. I know it can be done like this:
await page.type('input[name=pickup]', 'test comment', {delay: 200})
But what if the input box does not have a name or id, and instead it has a value name or title id? Like this:
await page.type('[title id^="pickupAgingComment"]', 'test comment', {delay: 200})
OR
await page.type('[value name^="pickupAgingComment"]', 'test comment', {delay: 200})
The last two does not work actually.
Submitting a form with attachments async function uploadFile() { const browser = await puppeteer. launch({ headless: false }); const page = await browser. newPage(); await page. goto('https://www.w3schools.com/howto/howto_html_file_upload_button.asp'); const element = await page.
Just set value of input like this: await page. $eval('#email', el => el. value = '[email protected]');
puppeteer find element by text You have to form XPath based on the text so that you can find the element. Once you form the XPath then you can use the $x method to find the element.
ok, I just figured out with this:
await page.type('input[name=pickupAgingComment]', 'test comment', {delay: 20})
Though the selector is a value name, I tried removing value and used just name literal. It is working for value name also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With