I am trying to write some code to detect the login form for any website (basically trying to recreate something like 1Password where I can detect the username/password field). I wanted to figure out which inputs are the right ones to input based on the attributes of the elements. When using puppeteer on sample html like:
<form class="">
<input type="text" id="id1" name="some name" placeholder="some placeholder" value="">
<input type="text" id="id2" attr1="some name" attr2="some placeholder" value="">
<input type="text" attr3="some name" attr4="some placeholder" value="">
</form>
code for Puppeteer is:
const inputHandles = await page.$$('input')
inputHandles.forEach(async(element) => {
// This actually works and gives me the id of each of the elements
const jsHandle = await (await element.getProperty('id')).jsonValue();
// This always returns {}
console.log(await element.getProperties())
})
I was wondering how I would be able to dynamically get the attributes of each of the inputs without querying for id/name/placeholder specifically. I also saw that the same issue as posted on github (https://github.com/puppeteer/puppeteer/issues/4995); however, it was closed for inactivity. Thanks!